JavaScript Polyfills On The Fly Depending On The Browser With

September 12, 2020 by Andreas Wik is a neat service that lets you load polyfills for certain JavaScript features only if the visitor’s browser actually needs it.

One thing I’ve used it for myself has been when an external library may be using an ES6 feature that’s not necessarily supported in older browsers. checks what browser makes the request, and depending on that it returns the necessary polyfills.

I can then simply include the following on my page, before the library:

<script type="text/javascript" src=""></script> will now return any polyfills that the browser may need.


You can also decide to only request polyfills for certain features that you know are used in your code. Let’s say we specifically need a polyfill for Object.assign if the browser doesn’t support it. We would then add on a features parameter (which should be a comma separated list if more than one):

<script type="text/javascript" src=""></script>


Check out for more details.

Share this article

Recommended articles