Minify your JavaScript

Online JavaScript Minifier/Compressor. Free! Provides an API. Simple Quick and Fast.

Written and hosted by Andrew Chilton (@andychilton).

Node.js

var querystring = require('querystring');
var http  = require('http');

var query = querystring.stringify({
    input : js
});

var req = http.request(
    {
        method   : 'POST',
        hostname : 'javascript-minifier.com',
        path     : '/raw',
    },
    function(resp) {
        // if the statusCode isn't what we expect, get out of here
        if ( resp.statusCode !== 200 ) {
            console.log('StatusCode=' + resp.statusCode);
            return;
        }

        resp.pipe(process.stdout);
    }
);
req.on('error', function(err) {
    throw err;
});
req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
req.setHeader('Content-Length', query.length);
req.end(query, 'utf8');

Language Examples

Click on the language of your choice:

wget Curl Node.js Python Java Ruby Perl PHP C#

More Languages

I'd love to add more examples in your favourite programming language, so feel free to send them my way. Email andychilton at that gmail place in the sky or tweet to me @andychilton.