Das Stylesheet wird gelesen statt durch pauschale Ersetzungen geschickt, und das ist wichtig, weil ein Stylesheet Zeichenketten enthält. Text in Anführungszeichen und innerhalb von url() wird beiseitegelegt, bevor irgendetwas zusammengezogen wird, und danach zurückgestellt — eine Kommentarfolge in einem content-Wert bleibt also wie sie war, und die Abstände in einer Zeichenkette bleiben unangetastet.
Kommentare werden entfernt, Leerraum außerhalb von Zeichenketten zusammengezogen und der Abstand um die strukturellen Satzzeichen — geschweifte Klammern, Semikola, Kommas und der Doppelpunkt einer Deklaration — entfällt, ebenso das letzte Semikolon jedes Blocks. Kommentare, die mit einem Ausrufezeichen beginnen, bleiben stehen, denn das ist die Konvention für einen Lizenzhinweis.
Was bewusst unangetastet bleibt
-
Die Operatoren in calc() behalten ihre Leerzeichen:
Die Rechenoperatoren brauchen Leerraum, um gelesen zu werden, und calc(100% - 20px) funktioniert nicht mehr, sobald er fehlt. Um ein Plus oder Minus herum wird nichts angefasst.
-
Nichts wird umsortiert oder zusammengeführt:
Doppelte Regeln bleiben doppelt, Kurzschreibweisen werden nicht verdichtet und Eigenschaften nicht sortiert. Das leistet ein vollwertiger Prozessor, und jede dieser Umformungen birgt ein Risiko, das hier nicht eingegangen wird.
-
Der Inhalt von url() bleibt erhalten:
Eine URL ohne Anführungszeichen kann Zeichen enthalten, die sonst wie Struktur aussähen, sie wird deshalb als Ganzes beiseitegelegt.
-
Die Ersparnis ist bescheiden und sicher:
Rechnen Sie mit der Größe der Kommentare und der Einrückung. Eine Build-Pipeline mit einem echten CSS-Prozessor schafft mehr — dies ist für eine Datei, die keine hat.
Why a stylesheet gets scanned rather than blanket-replaced
A stylesheet contains strings, and a minifier that does not know that will happily collapse whitespace sitting inside a quoted value or a `url()`. The [msm_tool slug="css-minifier"] sets both aside before anything is touched and restores them afterwards, so a comment-like sequence written inside a `content` value stays exactly as written rather than being misread as a real comment.
calc() keeps every one of its spaces
The arithmetic operators inside `calc()` need surrounding whitespace to parse at all — `calc(100% - 20px)` stops working the instant those spaces disappear. Nothing around a plus or minus sign inside a `calc()` expression is touched, specifically because that particular whitespace is not decorative.
Nothing is reordered, merged or condensed
Duplicate rules stay duplicated, shorthand properties are not combined, and declarations are not sorted or restructured in any way. Those transformations are what a full CSS processor does, and each one carries a risk of changing what the stylesheet actually means — a risk this tool deliberately does not take on.
url() contents come through whole
An unquoted URL can contain characters that would otherwise look like structural punctuation to a naive scanner, so the entire `url()` value is set aside and restored untouched rather than being parsed as ordinary CSS text.
Licence comments survive on purpose
A comment starting with an exclamation mark is kept rather than stripped, following the same convention used for licence headers elsewhere — every other comment is removed, but this specific exception is deliberate rather than an oversight.
What kind of saving to actually expect
The reduction here is roughly the size of the comments and the indentation that were removed, not the deeper savings a dedicated build-time CSS processor achieves through restructuring. For a file with no processing pipeline behind it, that modest, safe reduction is the entire point.