What minification removes
Minification only strips characters that carry no meaning to a browser. The parsed result is identical; the file is just smaller.
What each option does
| Removed |
Example |
Safe? |
| Whitespace and line breaks |
.a { color: red; } → .a{color:red} |
Always |
| Comments |
/* header */ |
Yes, unless you need a licence header |
| Final semicolon in a block |
color:red;} → color:red} |
Yes — CSS allows it |
| Redundant hex digits |
#ffffff → #fff |
Yes — identical colour |
How much you actually gain
Minification typically removes 20–50% of a hand-written stylesheet's bytes, and more from heavily commented or deeply indented source.
Be realistic about the effect, though: almost every server already applies gzip or Brotli compression, and those algorithms are very good at collapsing the repetitive whitespace that minification removes. The additional saving from minifying on top of gzip is real but modest — often in the region of 5–15% of the compressed size.
The bigger win on most sites is not minification but removing CSS that is never used. A framework shipped whole and used partially is a far larger cost than the whitespace in it.
Keep the readable version
Minified CSS is a build output. Edit the readable source, keep that in version control, and minify as part of the deploy step so the two never drift apart.
If you have inherited a minified file with no source, the HTML and CSS beautifier will reformat it into something readable — though comments removed during minification are gone for good.
Where a build pipeline exists, use it rather than pasting files by hand. Source maps let the browser show you the original file while the visitor downloads the minified one, which a manual round trip cannot do.
Beyond minification
If CSS is a real performance problem for you, these usually matter more than the byte count.
- Remove unused rules. Tools that analyse your pages and drop unreferenced selectors routinely cut a framework by most of its weight.
- Inline the critical CSS needed for the first screenful and load the rest asynchronously, so rendering is not blocked.
- Serve compressed. Brotli or gzip on the server does more than minification alone.
- Split by route so a visitor downloads the rules for the page they asked for, not for every page on the site.
- Prune old vendor prefixes. Prefixes for browsers nobody runs are pure weight.