Performance · JavaScript and CSS

Unminified JavaScript

This page loads a script that keeps all its comments, long names and white space. Minified, it would be much smaller to download.

How this page is built

The squares below are labelled by unminified.js: hover over one to see its number. The script is written for people to read, with a comment for every step and long variable names, so a minifier could remove most of it. Every line runs, so the file is not reported as unused JavaScript.

Why it matters

Browsers do not need comments, white space or long variable names to run a script. Minifying removes them and shortens names, which makes the file smaller and faster to download and parse.

JavaScript is the most expensive resource on most pages, so savings here help both loading and interactivity.

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 lists scripts that could be minified and the saving for each.

How to fix it

Minify JavaScript as part of the build, with a tool such as esbuild or Terser, and serve source maps if you need to debug the live site.

Back to all tests