Quantcast
Channel: CSS-TricksCSS-Tricks
Viewing all articles
Browse latest Browse all 31

Replacements for setInterval Using requestAnimationFrame

$
0
0

When it comes to animation, we're told that setInterval is a bad idea. Because, for example, the loop will run regardless of anything else going on, rather than politely yielding like requestAnimationFrame will. Also some browsers might "play catchup" with a setInterval loop, where an inactive tab might have been queuing iterations and then run them all very quickly to catch up when it becomes active again.

If you'd like to use setInterval, but want the performance politeness of requestAnimationFrame, the internet has some options available!

(more…)


Viewing all articles
Browse latest Browse all 31

Trending Articles