1JavaScript::Minifier(3)User Contributed Perl DocumentatioJnavaScript::Minifier(3)
2
3
4

NAME

6       JavaScript::Minifier - Perl extension for minifying JavaScript code
7

SYNOPSIS

9       To minify a JavaScript file and have the output written directly to
10       another file
11
12         use JavaScript::Minifier qw(minify);
13
14         open(my $in, 'myScript.js') or die;
15         open(my $out, '>', 'myScript-min.js') or die;
16
17         minify(input => $in, outfile => $out);
18
19         close($in);
20         close($out);
21
22       To minify a JavaScript string literal. Note that by omitting the
23       outfile parameter a the minified code is returned as a string.
24
25         my $minifiedJavaScript = minify(input => 'var x = 2;');
26
27       To include a copyright comment at the top of the minified code.
28
29         minify(input => 'var x = 2;', copyright => 'BSD License');
30
31       To treat ';;;' as '//' so that debugging code can be removed. This is a
32       common JavaScript convention for minification.
33
34         minify(input => 'var x = 2;', stripDebug => 1);
35
36       The "input" parameter is mandatory. The "output", "copyright", and
37       "stripDebug" parameters are optional and can be used in any
38       combination.
39

DESCRIPTION

41       This module removes unnecessary whitespace from JavaScript code. The
42       primary requirement developing this module is to not break working
43       code: if working JavaScript is in input then working JavaScript is
44       output. It is ok if the input has missing semi-colons, snips like '++
45       +' or '12 .toString()', for example. Internet Explorer conditional
46       comments are copied to the output but the code inside these comments
47       will not be minified.
48
49       The ECMAScript specifications allow for many different whitespace
50       characters: space, horizontal tab, vertical tab, new line, carriage
51       return, form feed, and paragraph separator. This module understands all
52       of these as whitespace except for vertical tab and paragraph separator.
53       These two types of whitespace are not minimized.
54
55       For static JavaScript files, it is recommended that you minify during
56       the build stage of web deployment. If you minify on-the-fly then it
57       might be a good idea to cache the minified file. Minifying static files
58       on-the-fly repeatedly is wasteful.
59
60   EXPORT
61       Exported by default: "minifiy()"
62

SEE ALSO

64       This module is inspired by Douglas Crockford's JSMin:
65       <http://www.crockford.com/javascript/jsmin.html>
66
67       You may also be interested in the CSS::Minifier module also available
68       on CPAN.
69

REPOSITORY

71       You can obtain the latest source code and submit bug reports on the
72       github repository for this module:
73       <https://github.com/zoffixznet/JavaScript-Minifier>
74

MAINTAINER

76       Zoffix Znet "<zoffix@cpan.org>" <https://metacpan.org/author/ZOFFIX>
77

AUTHORS

79       Peter Michaux, <petermichaux@gmail.com>
80
81       Eric Herrera, <herrera@10east.com>
82

CONTRIBUTORS

84       Miller 'tmhall' Hall
85
86       Вячеслав 'vti' Тихановский
87
89       Copyright (C) 2007 by Peter Michaux
90
91       This library is free software; you can redistribute it and/or modify it
92       under the same terms as Perl itself, either Perl version 5.8.6 or, at
93       your option, any later version of Perl 5 you may have available.
94
95
96
97perl v5.30.1                      2020-01-30           JavaScript::Minifier(3)
Impressum