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

295
Views
JS: setInterval has weird behavior with chrome throttling

I was testing my website out with chrome throttling, using the low-end mobile. I noticed one of my JS intervals were running much slower than it should be for no reason. I decided to investigate further, so I wrote this code:

let prev = Date.now();
let x = 0;
setInterval(() => {
  if(x++ % 100 == 0) {
    console.log(Date.now() - prev);
    prev = Date.now();
  }
}, 10);

It sets an interval to run every 10ms, and it prints the time elapsed every 100 runs. This should be 1 second, but it is printing 4-8 seconds. This shouldn't happen, because getting the date every 100 runs, and then logging it, should be a piece of cake, even for "low-end mobile".

My best guess right now is that chrome's throttling also specifically throttles the event loop, which sometimes gives misleading results, like here. Is this true?

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!