Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Any way to make this simple code more efficient/appear to run more smoothly? (css/js parallax)

I created a simple parallax effect for a hero image:

https://jsfiddle.net/176ns5f3/

    <header role="presentation" class="parallax">
    </header>
    <article>
    </article>
window.addEventListener("scroll", throttle(scroll, 15));
function throttle(fn, wait) {
  var time = Date.now();
  return function () {
    if (time + wait - Date.now() < 0) {
      fn();
      time = Date.now();
    }
  };
}
let parallax = document.querySelector(".parallax");

function scroll() {
  var currentScrollPos = window.pageYOffset;
  var coords = currentScrollPos * 0.5 + "px";
  parallax.style.transform = "translate3d(0," + coords + ",0)";
  
}

It runs fine on my i7 laptop however on older devices it is a bit stuttery.

I created my own js as I thought it would be more efficient however it doesn't seem to be the case?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!