DEV Community

Joan Alba Maldonado
Joan Alba Maldonado

Posted on • Originally published at joanalbamaldonado.com on

4 1

requestAnimationFrame (with high resolution timing, very precise) and 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!

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong · web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video 🌶️🔥

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay