autominify

Auto-minifier middleware for js files in an express-served node.js project

Autominify

Node.js Express Auto-minifier middleware for javascript.

We expect you to be using connect or Express.

When Express receives a request for a javascript file, we check to see if it's already minified (ends in .min.js) and if not, then we create a serve a minified file instead.

For debugging, you can append a url variable of &autominify=false and the original files will be served instead.

var autominify = require("autominify");
//defaults to gcc (google closure compiler)
app.use(autominify(path.join(__dirname, 'public', 'js')));
var autominify = require("autominify");
app.use(autominify(path.join(__dirname, 'public', 'js')));
app.use(autominify(path.join(__dirname, 'public', 'javascripts')));
app.use(autominify(path.join(__dirname, 'public', 'javascript')));
var autominify = require("autominify");
app.use(autominify(path.join(__dirname, 'public', 'js'), 'yui-js'));
  • no-compress
  • yui-js
  • gcc
  • uglifyjs