A correctness test suite for CSS minifiers.
This project exists in good faith to improve all CSS tooling. It is not a leaderboard and it is not intended to declare winners or call out losers. Every minifier makes different trade-offs and every score reflects a snapshot in time. The goal is to give maintainers a shared, vendor-neutral corpus of transformations they can run against their own tool to find gaps and edge cases.
Inspired by Romain Menke's css-tokenizer-tests, which provides a similar community-driven corpus for CSS tokenizers; a project that helped raise the bar for tokenizer correctness across the ecosystem. The hope is that this suite can do the same for minification.
The suite contains hundreds of tests organised by category. Each test isolates one minification technique so failures are easy to diagnose:
tests/
<category>/
<NNNN>/
source.css # Unminified input
expected.css # Canonical minified output (single line)
README.md # Short description of the transformation
validate.html # Optional browser-viewable proof of equivalenceCategories include at-rules, colors, comments, duplicates, gradients, merging, nesting, selectors, shorthands, transforms, values, vendors, whitespace, zero-units, and more.
Running npm t feeds every source.css through each minifier, compares the
output to expected.css, and prints a summary table.
- You'll need to be on the correct Node an npm versions defined in the
package.json. Use a tool like Proto or Mise to handle switching your versions automatically. - Run
npm ito install dependencies - Run
npm tto execute the test suite
Want to add your minifier to the suite? See the contributing guide for the full walk-through. In short:
- Create an adapter in
lib/minifiers/<name>.jsthat exports a defaultminify(source)function returning the minified CSS string. - Register it in
lib/loaders/loadAllMinifiers.js. - Add the npm package to
devDependencies. - Run
npm testand open a PR. - Update the README to add it to the list of "Tested minifiers"
See CONTRIBUTING.md for how to add tests, verify transformations against the spec, and interpret results. In short:
- Run
npm run new-test categorywherecategoryis the name of one of the category (or a new category if you can't find an appropriate existing one). - Edit the generated files.
- Run
npm testand open a PR.
MIT