Performance · JavaScript and CSS
Legacy JavaScript
This page loads polyfills for array, string, number and maths methods that every current browser already supports, so the code is never needed.
How this page is built
The page loads legacy.js, which defines more than 40 polyfills, such as Array.prototype.at, String.prototype.padStart and Object.entries. Each one checks whether the browser already has the method, so none of them replaces a built-in method. The script then uses two of those methods to write the result below.
Result from the script: loading
Why it matters
Polyfills add missing features to old browsers. Modern browsers already have those features, so for almost every visitor the polyfill code is downloaded and parsed for nothing. Build tools often add them by default, aimed at browsers that are no longer in use.
The cost grows with each polyfill, and large polyfill libraries can add tens of kilobytes to every page.
How to check it
Run Lighthouse or PageSpeed Insights on the page and look at the diagnostics. Crawl tools that run Lighthouse for each page, or that measure page resources, report the same finding across the site. Lighthouse names the script and the polyfills or transforms it found. Search the code for lines such as Array.prototype.at = to find them yourself.
How to fix it
Set the build tool’s browser targets to the browsers your visitors really use, for example with a browserslist query such as defaults and fully supports es6-module. Remove polyfill libraries you no longer need, or serve them only to browsers that lack the feature.