DEV Community

Discussion on: When to use setTimeout vs setInterval?

Collapse
 
krhoyt profile image
Kevin Hoyt • Edited

In some cases, requestAnimationFrame() can/should be used in place of setInterval(). Mostly, as the name suggests, for animation, which I would extend to mean any time your “interval” is updating the DOM. This way you keep in step with the browser repaint, which can streamline rendering and improve performance.

Collapse
 
skaytech profile image
skaytech

Thanks for sharing this Kevin. Appreciate it!