-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Polyfill.io is a really interesting polyfill-as-a-service open-source project. The idea is that it serves polyfills to specific JavaScript features only if the browser of the user requesting them doesn't already support them natively. For example, check https://cdn.polyfill.io/v2/polyfill.js?features=fetch on a modern browser (one that supports fetch) and you'll see that no JS is served.
This has two major benefits over including polyfills manually:
- You don't have to worry about managing and including polyfills in your codebase. You write modern JS code and let the Polyfill service handle compatibility issues at the edge;
- You're not serving polyfills to people that natively support them, avoiding sending unnecessary data across the wire.
The code behind Polyfill.io is available on GitHub and even though it can work as a standalone server, it can also be used as a Node.js module.
My think is that we could use it to extend CDN with the ability to automatically polyfill JS files. So you'd serve your JS file with modern code and CDN would inject any necessary polyfills depending on the client's browser.
I'm happy to have a stab at this if we think it's worth pursuing.