News Score: Score the News, Sort the News, Rewrite the Headlines

Why do browsers throttle JavaScript timers?

Even if you’ve been doing JavaScript for a while, you might be surprised to learn that setTimeout(0) is not really setTimeout(0). Instead, it could run 4 milliseconds later: const start = performance.now() setTimeout(() => { // Likely 4ms console.log(performance.now() - start) }, 0) Nearly a decade ago when I was on the Microsoft Edge team, it was explained to me that browsers did this to avoid “abuse.” I.e. there are a lot of websites out there that spam setTimeout, so to avoid draining the use...

Read more at nolanlawson.com

© News Score  score the news, sort the news, rewrite the headlines