.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "JavaScript::Minifier 3pm" .TH JavaScript::Minifier 3pm "2018-04-02" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JavaScript::Minifier \- Perl extension for minifying JavaScript code .SH "SYNOPSIS" .IX Header "SYNOPSIS" To minify a JavaScript file and have the output written directly to another file .PP .Vb 1 \& use JavaScript::Minifier qw(minify); \& \& open(my $in, \*(AqmyScript.js\*(Aq) or die; \& open(my $out, \*(Aq>\*(Aq, \*(AqmyScript\-min.js\*(Aq) or die; \& \& minify(input => $in, outfile => $out); \& \& close($in); \& close($out); .Ve .PP To minify a JavaScript string literal. Note that by omitting the outfile parameter a the minified code is returned as a string. .PP .Vb 1 \& my $minifiedJavaScript = minify(input => \*(Aqvar x = 2;\*(Aq); .Ve .PP To include a copyright comment at the top of the minified code. .PP .Vb 1 \& minify(input => \*(Aqvar x = 2;\*(Aq, copyright => \*(AqBSD License\*(Aq); .Ve .PP To treat ';;;' as '//' so that debugging code can be removed. This is a common JavaScript convention for minification. .PP .Vb 1 \& minify(input => \*(Aqvar x = 2;\*(Aq, stripDebug => 1); .Ve .PP The \*(L"input\*(R" parameter is mandatory. The \*(L"output\*(R", \*(L"copyright\*(R", and \*(L"stripDebug\*(R" parameters are optional and can be used in any combination. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module removes unnecessary whitespace from JavaScript code. The primary requirement developing this module is to not break working code: if working JavaScript is in input then working JavaScript is output. It is ok if the input has missing semi-colons, snips like '++ +' or '12 .\fItoString()\fR', for example. Internet Explorer conditional comments are copied to the output but the code inside these comments will not be minified. .PP The ECMAScript specifications allow for many different whitespace characters: space, horizontal tab, vertical tab, new line, carriage return, form feed, and paragraph separator. This module understands all of these as whitespace except for vertical tab and paragraph separator. These two types of whitespace are not minimized. .PP For static JavaScript files, it is recommended that you minify during the build stage of web deployment. If you minify on-the-fly then it might be a good idea to cache the minified file. Minifying static files on-the-fly repeatedly is wasteful. .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" Exported by default: \f(CW\*(C`minifiy()\*(C'\fR .SH "SEE ALSO" .IX Header "SEE ALSO" This module is inspired by Douglas Crockford's JSMin: .PP You may also be interested in the CSS::Minifier module also available on \s-1CPAN.\s0 .SH "REPOSITORY" .IX Header "REPOSITORY" You can obtain the latest source code and submit bug reports on the github repository for this module: .SH "MAINTAINER" .IX Header "MAINTAINER" Zoffix Znet \f(CW\*(C`\*(C'\fR .SH "AUTHORS" .IX Header "AUTHORS" Peter Michaux, .PP Eric Herrera, .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" Miller 'tmhall' Hall .PP Вячеслав 'vti' Тихановский .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2007 by Peter Michaux .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.