If you have spent any time developing with jQuery, you've most likely created some form of animation that included managing changes at a regular frequency—does this sound familiar?
We can, of course, use the setInterval()
function for this, but it—like the setTimeOut()
function—is not ideal. Both these functions have a delay before being initiated, which varies from browser to browser; they are both equally resource intensive!
Instead, we can use the requestAnimationFrame (rAF) API, which is now supported by most modern browsers, according to this chart from caniuse.com where green labels show which browser versions support requestAnimationFrame:
The great thing about the requestAnimationFrame API is that it is less resource-intensive, doesn't impact other elements on the page, and is disabled when it loses focus (perfect for reducing power usage!). You may think, therefore, that it makes sense to implement it in jQuery by default, right?