How to think about Baseline and polyfills

Published: March 18, 2025

Polyfills have long been a part of the web developer experience, as they attempt to provide support for web features that aren't supported in all browsers. It would seem that polyfills are an indispensable tool in the web developer's toolkit, but it's nearly impossible to distill such a complex area of concern into a single, definitive statement.

Knowing when to use a polyfill for a feature depends on its availability across browsers, and Baseline can be helpful in making that determination. While Baseline doesn't tell you whether or not you should use polyfills, the clarity it brings to the availability of web platform features gives you an opportunity to be more selective, as excessive polyfills in an application can have significant drawbacks.

What are polyfills?

A polyfill is code that evaluates support for a feature in a browser, and—if the feature is unsupported—it will use JavaScript to attempt to provide that missing functionality.

An early example of a polyfill is Matchmedia.js, which used JavaScript to detect and provide support for the matchMedia method. matchMedia lets developers evaluate whether a media query matches the state of the current viewport in JavaScript. By loading a polyfill to provide the missing feature, it became possible to use the matchMedia method in any browser—but this polyfill is now no longer necessary, as matchMedia is available in nearly every browser in use.

While adding support for unsupported features is advantageous in some ways, the disadvantages of polyfills often go overlooked. As the number of polyfills increase in a web application, they can begin to have negative impacts.