Minify your JavaScript

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

Digital Ocean

Written and hosted by Andrew Chilton (@andychilton).

We recommend Digital Ocean for hosting your sites. Free $10 credit when you sign up.

Perl

Thanks to Boris Kotyrev (I've adapted what he sent to be more minimal).

use strict;
use warnings;

use File::Slurp;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

sub minify{
    my ($js) = @_;

    my $js_min_url = "https://javascript-minifier.com/raw";

    my $ua = LWP::UserAgent->new;
    my $request = POST($js_min_url, [ 'input' => $js ]);
    my $js_min = $ua->request($request)->decoded_content();

    return $js_min;
}

print minify($js, "\n");

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.