NAME

Javascript::Closure - compress your javascript code using Google online service of Closure Compiler

VERSION

1.03

SYNOPSIS

    use Javascript::Closure qw(minify); 

	#open a file
	open (FILE,'<','jscript.js') or die $!;
	my @lines = <FILE>;
	close FILE;
	
	#compress the code
    my $compressed   = minify(input=>join('',@lines));
    
    #output the result in another file
	open FILE,'>','closure-jscript.js' or die $!;
	print FILE $compressed;
	close FILE;
	
	#you can add options:
	my $compressed = minify(input            => $string,
							output_format    => Javascript::Closure::XML,
							output_info      => Javascript::Closure::STATISTICS,
							compilation_level=> Javascript::Closure::ADVANCED_OPTIMIZATIONS
	);

DESCRIPTION

This package allows you to compress your javascript code by using the online service of Closure Compiler offered by Google via a REST API. See http://closure-compiler.appspot.com/ for further information.

MOTIVATION

Needed a package to encapsulate a coherent API for a future Javascript::Minifier::Any package.

ADVANTAGES

Gives you access to the closure compression algo with an unified API.

SUBROUTINES/METHODS

minifier(input= scalar,compilation_level=>scalar,output_info=>scalar,output_format=>scalar)>

Takes an hash that should contain input as a key and a javascript code a value or an url starting by http://. If you do not supply an input, it will output a dummy compression set of data.

Other are options set by default:

- compilation_level: 
   WHITESPACE_ONLY
   SIMPLE_OPTIMIZATIONS (default)
   ADVANCED_OPTIMIZATIONS
   
- output_info:
    compiled_code (default)
    warnings
    errors
    statistics
    
- output_format:
    text (default)
    json
    xml

Return the compressed version of the javascript code as a scalar by default.

DIAGNOSTICS

Fail to connect to http://closure-compiler.appspot.com/compile:...

The module could not connect and successfully compress your javascript. See the detail error to get a hint.

SEE ALSO

Javascript::Minifier Javascript::Packer JavaScript::Minifier::XS http://closure-compiler.appspot.com/

CONFIGURATION AND ENVIRONMENT

none

DEPENDENCIES

LWP::UserAgent

INCOMPATIBILITIES

none

BUGS AND LIMITATIONS

If you do me the favor to _use_ this module and find a bug, please email me i will try to do my best to fix it (patches welcome)!

AUTHOR

shiriru <shiriru0111[arobas]hotmail.com>

LICENSE AND COPYRIGHT

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 162:

'=item' outside of any '=over'