← All blog posts

Common mistakes people make with the CSS Minifier

WhiteUI · A plain-English guide to the CSS Minifier

Most wrong results from the CSS Minifier are not faults in the tool. The tool applies four fixed rules, so when the output looks wrong, the input or the next step is usually the cause. The five mistakes below are the ones that come up most often, and each has a quick fix.

At a glance

A rule with a string: 75 bytes0 bytes45 bytes91 bytes91 bytes → 75 bytes, 16 saved
A rule with a quoted file name and a calc() value goes from 91 bytes to 75 bytes, saving 16 bytes.

Mistake 1: minifying the output a second time

People paste the minified output back into the tool and expect it to shrink again. It will not: minifying the 68-byte sample gives back the same 68 bytes, saving 0, because the comments and extra spaces are already gone. A saved figure of 0 on a second pass means the CSS is already minified, not that the tool has stopped working. Minify once, then use the output.

Mistake 2: hand-editing the minified output

The output is one long line, and it is tempting to fix a colour or a width in it directly. Do not: the minified version has no comments and no readable layout, so a small edit is easy to get wrong, and the original is the only version that is easy to check. Change the readable original instead, then minify a fresh copy. That way the original and the published version always match.

Mistake 3: pasting HTML instead of CSS

The tool expects CSS, not a whole web page. If you paste HTML, the tool will still remove spaces and semicolons, but the result is not valid CSS and will not work as a stylesheet. Paste only the contents of a style tag or a .css file. If your CSS lives inside a page, copy from the opening brace of the first rule to the closing brace of the last rule, and leave the tags out.

Mistake 4: assuming quoted text will be damaged

People worry that a file name with a space, such as "my photo.jpg", will lose its space, or that a calc() value will break. It will not: the tool copies quoted strings untouched, and the spaces around the minus sign in calc(100% - 20px) survive, because a minus sign is not one of the punctuation marks the tool strips spaces around. A rule with both of those goes from 91 bytes to 75 bytes, saving 16 bytes, with the string and the calculation intact. The safe check is to load the page after minifying and look at it.

Mistake 5: losing the original file

This is the costly one. If you overwrite your only copy of a stylesheet with its minified version, the comments are gone for good, and the readable layout with them. Keep the original file, with its comments and line breaks, and save the minified output under a different name, such as style.min.css. Then a later change means editing the original and minifying again, which takes seconds, instead of rebuilding a stylesheet from a single long line.

Worked check

Check any answer against the anchor: the default sample is 105 bytes and minifies to 68 bytes, saving 37. If your own CSS saves far less than you expected, look at how it was written: a stylesheet that was already tight, with short lines and no comments, has little to save. The percentage only tells you how much dead weight the original was carrying, not whether the tool worked.

Frequently asked questions

What is the most common CSS Minifier mistake?

Minifying the output a second time and expecting it to shrink again. Minifying the 68-byte sample gives back the same 68 bytes, saving 0.

Should I edit the minified CSS directly?

No. Edit the readable original and minify a fresh copy, so the two versions always match.

Does minifying damage quoted file names?

No. Strings in quotes are copied untouched, so "my photo.jpg" keeps its space.

What should I do with the original file?

Keep it. Save the minified output under a different name, such as style.min.css, so you can edit the original later.

More guides on the CSS Minifier

Try it yourself

Try the CSS Minifier — free, in your browser.

Open the CSS Minifier