JavaScript::Packer(3pm) | User Contributed Perl Documentation | JavaScript::Packer(3pm) |
JavaScript::Packer - Perl version of Dean Edwards' Packer.js
Version 2.10
A JavaScript Compressor
This module is an adaptation of Dean Edwards' Packer.js.
Additional information: http://dean.edwards.name/packer/
use JavaScript::Packer; my $packer = JavaScript::Packer->init(); $packer->minify( $javascript, $opts );
To return a scalar without changing the input simply use (e.g. example 2):
my $ret = $packer->minify( $javascript, $opts );
For backward compatibility it is still possible to call 'minify' as a function:
JavaScript::Packer::minify( $javascript, $opts );
The first argument must be a scalarref of javascript-code.
Second argument must be a hashref of options. Possible options are:
/* JavaScript::Packer _no_compress_ */ /* JavaScript::Packer shrink */
#!/usr/bin/perl use strict; use warnings; use JavaScript::Packer; my $packer = JavaScript::Packer->init(); open( UNCOMPRESSED, 'uncompressed.js' ); open( COMPRESSED, '>compressed.js' ); my $js = join( '', <UNCOMPRESSED> ); $packer->minify( \$js, { compress => 'best' } ); print COMPRESSED $js; close(UNCOMPRESSED); close(COMPRESSED);
#!/usr/bin/perl use strict; use warnings; use JavaScript::Packer; my $packer = JavaScript::Packer->init(); open( UNCOMPRESSED, 'uncompressed.js' ); open( COMPRESSED, '>compressed.js' ); my $uncompressed = join( '', <UNCOMPRESSED> ); my $compressed = $packer->minify( \$uncompressed, { compress => 'best' } ); print COMPRESSED $compressed; close(UNCOMPRESSED); close(COMPRESSED);
Merten Falk, "<nevesenin at cpan.org>". Now maintained by Lee Johnson (LEEJO)
This module will break code that relies on ASI, see <https://github.com/leejo/javascript-packer-perl/issues/5> for more information.
This module uses regular expressions to parse the JavaScript so is prone to bugs and edge cases, especially when the JavaScript standard is updated
Please report any bugs or feature requests through the web interface at <http://github.com/leejo/javascript-packer-perl/issues>.
You can find documentation for this module with the perldoc command.
perldoc JavaScript::Packer
Copyright 2008 - 2012 Merten Falk, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2024-03-05 | perl v5.38.2 |