+ 11

What's the difference between setInterval() and requestAnimationFrame()

Which better to use?

4th May 2017, 8:55 AM
Wisdom Abioye
Wisdom Abioye - avatar
2 Réponses
+ 7
SetInterval() is less accurate than requestAnimationFrame() but more better supported by browsers ^^ SetInterval() wait for a delay before calling a function ( if you use it with a kind of recursivity by passing the actual function to it, the delay parameter doesn't include the time of code execution ), while requestAnimationFrame is designed for handle more accurate clocking functions by call them at a parameter frequency rather than a delay ( function call occurs every n times )
4th May 2017, 3:10 PM
visph
visph - avatar