"Minify your CSS and HTML" is one of the first pieces of speed advice anyone gets, and Lighthouse and PageSpeed Insights flag unminified files. It is good advice. It is also routinely oversold, as if a minifier were the fix for a slow site. We measured our own files to see how much it actually saves once real-world compression is involved.

The short answer: minifying removes roughly 15 to 25 percent of a CSS or HTML file, but servers compress files before sending them, and compression already removes most of the same redundancy. After compression the saving is usually a few kilobytes. Minification is free and worth doing, but if your site is slow, the cause is almost certainly somewhere else.

What minification removes

A minifier strips everything a browser does not need: comments, line breaks, indentation, spaces around braces and colons, the last semicolon in a block, and sometimes shortens values such as #ffffff to #fff. HTML minifiers also remove comments and collapse whitespace between tags. The page looks and behaves the same; the file is just smaller and unreadable to humans.

Our measurements

We took three of CachePlex's own stylesheets and one full HTML page, minified them, and compressed both versions with gzip at a typical server setting:

  • Main site stylesheet: 39.8 KB raw, 31.7 KB minified (20 percent smaller). Gzipped: 7.9 KB vs 6.4 KB. Saving over the network: about 1.5 KB.
  • Share Preview Checker stylesheet: 23.9 KB raw, 19.8 KB minified (17 percent). Gzipped: 5.2 KB vs 4.6 KB. Saving: about 0.7 KB.
  • Screenshot Generator stylesheet: 22.6 KB raw, 17.2 KB minified (24 percent). Gzipped: 5.1 KB vs 4.2 KB. Saving: about 0.9 KB.
  • A full HTML page (the Share Preview Checker): 91.6 KB raw, 77.0 KB minified (16 percent). Gzipped: 14.6 KB vs 13.7 KB, only 6 percent. Saving: under 1 KB.

Our site is actually served with Brotli compression, which squeezes files slightly further than gzip and narrows the gap again. On a typical mobile connection, one or two kilobytes is a millisecond or two of download time. That is real, but nobody will notice it.

Why compression shrinks the benefit

Compression works by finding repeated patterns and replacing them with short references. Indentation, repeated property names and long runs of whitespace are exactly the kind of repetition it handles best. So most of what a minifier removes, compression would have shrunk to almost nothing anyway. The two overlap; you do not get both savings in full.

When minification does matter

  • Your server does not compress files. Then minification is one of your only savings, and you should fix compression too. Check the Content-Encoding response header in your browser's developer tools; it should say gzip or br.
  • A development build went to production. Unminified framework files with source comments can be several times larger than their production versions. This is the case where minifying makes a dramatic difference.
  • Large CSS or JavaScript inlined into every page. Inline code cannot be cached separately, so it is downloaded again with every page view.
  • Very large files. Savings scale with size. A 500 KB stylesheet saves far more than a 20 KB one, though a 500 KB stylesheet has bigger problems than whitespace.

What moves page speed far more

If PageSpeed Insights says your site is slow, these usually matter more than minification:

  1. Images. The largest image on the page is often the Largest Contentful Paint element. Serving it at the right size and in a modern format usually saves more than every minifier combined. Our guide to reducing image file size without losing quality covers how.
  2. Unused CSS. A theme that loads styles for every possible component on every page ships kilobytes the page never uses. Lighthouse reports this as "Reduce unused CSS", and it often dwarfs the minify saving.
  3. Render-blocking resources. CSS and scripts in the head delay the first paint. Loading non-critical styles later and deferring scripts helps more than shrinking them.
  4. Caching. Long cache lifetimes for static files mean returning visitors download nothing at all.
  5. JavaScript. Heavy scripts slow down responsiveness after the page appears, which is what Interaction to Next Paint measures.

How to minify safely

If your site has a build process or a performance plugin, let it minify automatically and keep your source files readable. For one-off files, paste them into our CSS Minifier or HTML Minifier. Either way, test the page afterwards, because a few things can break:

  • Spaces inside calc(). calc(100% - 20px) needs the spaces around the minus sign. A careless minifier that removes them breaks the rule.
  • Whitespace between inline elements in HTML. The space between two inline links or buttons is real; collapsing it can make them touch.
  • <pre> and <textarea>. Whitespace inside them is content and must be left alone.
  • Licence comments. Comments starting with /*! are conventionally kept; check your minifier keeps them if the licence requires it.

Does minification help SEO?

Only through page speed, and as the numbers show, the effect is small. Google uses page experience signals, including Core Web Vitals, but a kilobyte or two will not move them in any measurable way. Minify because it is free and tidy. Do not expect a ranking change from it.

Frequently asked questions

Why does PageSpeed Insights still tell me to minify?

The audit flags any file it can shrink, however small the saving. Look at the estimated saving it shows next to the item. If it is a few kilobytes, it is a low priority.

Is it worth minifying HTML at all?

Our page dropped by 6 percent after compression. If your platform does it automatically, fine; if it means extra work or risk, the CSS, images and scripts are better uses of your time.

Should I combine CSS files as well?

Less than you used to. With HTTP/2 and HTTP/3, several small files load in parallel efficiently. Combining still helps when there are many tiny files, but it is no longer a rule.

Short version

Minification cuts 15 to 25 percent of a file, but compression already removes most of the same bytes, so the real saving is usually one or two kilobytes per file. Make sure compression is on, minify automatically if you can, and spend your speed effort on images, unused CSS, render-blocking files and caching, where the big wins are. To see how your pages do overall, run them through the SEO Analyzer.