DEV Community


requestAnimationFrame (with high resolution timing, very precise) and polyfills

jalbam profile image Joan Alba Maldonado Originally published at on ・1 min read

Two Vanilla JavaScript polyfills:

I have just adapted the window.requestAnimationFrame polyfill made by Paul Irish to work with high resolution timing automatically (when possible) and improved the performance a little bit. Here it is:

I have also mixed the polyfill made by Paul Irish with Aaron Levine’s and modified some of the code to improve it. Here it is:

Both polyfills can be used either separately or together and they will automatically detect whether the web client needs them or not. Just load them in your code (using your favourite way) and, if the client needs them, the polyfills will deploy and be used.

If you want to use them together, remember to load first the code of the polyfill since the window.requestAnimationFrame polyfill could need it.

Any comments are welcome!

Discussion (0)

Forem Open with the Forem app