Minify

Minifier of js, css, html and img

View Project on

Find typo? Help fix it.

Minify

Minify - a minifier of js, css, html and img files, used in Cloud Commander project.

To use minify as middleware try Mollify.

Install

NPM_INFO

You can install minify via npm:

npm i minify -g

Command Line

Command line syntax:

minify <input-file1> <input-file2> <input-fileN> > output
stdout | minify --<flag>

For example:

minify client.js util.js > all.js
minify screen.css reset.css > all.css

cat client.js | minify --js
cat *.css | minify --css

API

The Minify module contains an api for interacting with other js files.

minify = require('minify');

After minification, a file will be saved in the temporary directory.

minify - function to minificate js, html and css-files.

Possible options: - name - stream

Examples:

Optimize file

var minify = require('minify');

minify('client.js', 'name', function(error, name) {
    console.log(error || name);
});
minify('client.js', 'stream', function(error, stream) {
    var streamWrite = fs.createWriteStream('client.min.js');

    if (error)
        console.error(error.message);
    else
        stream.pipe(streamWrite);
});

if post processing is need:

minify('client.js', function(error, data) {

});

Optimize data

Parameters: - Data - Callback

Example:

minify.js('function hello() { if (2 > 3) console.log(\'for real\')}', function(error, data) {
    console.log(error, data);
});

minify.css('div { color: #000000}', function(error, data) {
    console.log(error, data);
});

Express middleware

To use as express middleware mollify could be used.

License

MIT