O'Reilly logo

Mastering jQuery by Alex Libby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating animation support in jQuery

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required