window.requestAnimationFrame (with high resolution timing, very precise) and window.performance.now polyfills

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: https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0

I have also mixed the window.performance.now polyfill made by Paul Irish with Aaron Levine’s and modified some of the code to improve it. Here it is: https://gist.github.com/jalbam/cc805ac3cfe14004ecdf323159ecf40e

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 window.performance.now polyfill since the window.requestAnimationFrame polyfill could need it.

Any comments are welcome!

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
10 ⁄ 5 =