README
1JavaScript-Squish
2=================
3
4This module provides methods to compact javascript source down to just
5what is needed. It can remove all comments, put everything on one line
6(semi-)safely, and remove extra whitespace.
7
8Any one of the various compacting techniques can be applied individually,
9or with in any group.
10
11It also provides a means by which to extract all text literals or
12comments in separate arrays in the order they appear.
13
14Since JavaScript eats up bandwidth, this can be very helpful, and you
15can then be free to properly comment your JavaScript without fear of
16burning up too much bandwidth.
17
18SYNOPSIS
19 use JavaScript::Squish;
20 my $compacted = JavaScript::Squish->squish(
21 $javascript,
22 remove_comments_exceptions => qr/copyright/i )
23 or die $JavaScript::Squish::err_msg;
24
25 # OR, to just do a few steps #
26
27 my $c = JavaScript::Squish->new();
28 $c->data( $javascript );
29 $c->remove_comments(exceptions => qr/copyright/i );
30 $c->replace_white_space();
31 $c->remove_blank_lines();
32 my $new = $c->data();
33
34
35INSTALLATION
36
37To install this module type the following:
38
39 perl Makefile.PL
40 make
41 make test
42 make install
43
44
45BUGS
46
47There are a few bugs, which may rear their head in some minor situations.
48
49Statements not terminated by semi-colon.
50 These should be ok now - leaving a note here because this hasn't
51 been thoroughly tested (I don't have any javascript to test with
52 that meets this criteria).
53
54 This would affect statements like the following:
55
56 i = 5.4
57 j = 42
58
59 This used to become "i=5.4 j=42", and would generate an error along
60 the lines of "expected ';' before statement".
61
62 The linebreak should be retained now. Please let me know if you see
63 otherwise.
64
65Ambiguous operator precidence
66 Operator precidence may get screwed up in ambiguous statements. Eg.
67 "x = y + ++b;" will be compacted into "x=y+++b;", which means some-
68 thing different.
69
70SEE ALSO
71
72Latest releases, bugzilla, cvs repository, etc:
73 https://developer.berlios.de/projects/jscompactor/
74
75Simlar projects:
76 http://crockford.com/javascript/jsmin
77 http://search.cpan.org/%7Epmichaux/JavaScript-Minifier/lib/JavaScript/Minifier.pm
78 http://dojotoolkit.org/docs/shrinksafe
79 http://dean.edwards.name/packer/
80
81
82AUTHOR
83
84Joshua I. Miller <jmiller@puriifeddata.net>
85
86
87COPYRIGHT AND LICENSE
88
89Copyright (c) 2005 by CallTech Communications, Inc.
90
91This library is free software; you can redistribute it and/or modify it
92under the same terms as Perl itself, either Perl version 5.8.3 or, at
93your option, any later version of Perl 5 you may have available.
94
95
96
97