Skip to content

Instantly share code, notes, and snippets.

@oalders
Forked from gugod/closure-complier.pl
Created November 8, 2009 03:57
Show Gist options
  • Save oalders/229089 to your computer and use it in GitHub Desktop.
Save oalders/229089 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
#
# Usage:
#
# closure-compiler.pl < file1.js file2.js file3.js ... > out.js
#
use strict;
use warnings;
use LWP::UserAgent;
local $\ = "\n";
local $/ = undef;
my $code = <>;
my $ua = LWP::UserAgent->new;
my $r = $ua->post("http://closure-compiler.appspot.com/compile", {
js_code => $code,
compilation_level => "ADVANCED_OPTIMIZATIONS",
output_info => "compiled_code",
output_format => "text"
});
if ($r->is_success) {
print $r->decoded_content;
}
else {
print "Error";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment