Image for post
Image for post


  • The setTimeout function is okay, but overall, for a 250ms theoretical timeout, the real/effective timeout value ranges from 251ms to 1.66+s.
  • As of October 2020, the most accurate way of scheduling a function/callback is using the setTimeout function in a Web Worker, in a cross-origin iframe.
  • The requestAnimationFrame function is the least accurate and requires to be inside the viewport, otherwise the real timeout can go up to several seconds, or even minutes.



Benoit Ruiz

Twitter: @Haaress

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store