node package manager

css-minifiers

css-minifiers Build Status NPM version Dependency Status

(almost) all CSS minifiers available for node.js

Why?

This module provides a convenient list of the CSS minifiers that are out there for the Node ecosystem, should you need to compare minification results across engines. It has mostly been inspired from the minification benchmark, and provides a simple, normalised API for all available tools.

Engine support

Engine Support
clean-css
crass
css-condense
css-smasher
cssnano
csso
cssshrink
csswring
more-css
ncss
sqwish
ycssmin

If you've written a minifier that you'd like to add to this list, please send a pull request!

Usage

Since version 2, all minifiers are wrapped with the Promise API:

var minifiers = require('css-minifiers');
var css = 'h1 { color: #880000; }';
var csso = minifiers.csso;
 
csso(css).then(function (output) {
    console.log(output);
    // => h1{color:#800} 
});

Get a benchmark compression time:

csso.bench(css).then(function (output) {
    console.log(output);
    // => 1.4 ms 
});
 
csso.bench(css, true).then(function (output) {
    console.log(output);
    // => 1.399856 ms 
});

The version number & homepage for the engine are also exposed:

console.log(csso.version, csso.url);
// => 1.3.11 https://github.com/css/csso 

Install

With npm do:

npm install css-minifiers

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs