jsjam [opts] file...
-d --debug Debug mode. -h --help Print help and exit. -q --quiet Quiet mode. -v --version Print version and exit.
-i --keep-identifiers Do not shorten identifiers. -g --keep-globals Do not shorten non-"var" identifiers. -w --keep-whitespace Do not compress whitespace. -n --keep-newlines Do not remove newlines following stuff. -c --keep-comments Do not compress comments (implies -n).
-a --add-note N Adds note "N" to the end of the compressed output (in a // comment).
The options --keep-identifiers and --keep-globals are not compatible.
The jsjam Perl script is available here:
The compressed output for all input files is sent to stdout.
Compression methods include:
- Strip comments.
- Strip unnecessary whitespace.
- Shorten identifiers (variable names, function names, field names).
where ``identifier'' is the identifier which should not be shortened.
jsjam --debug mycode.js >mycode-jsjam.js
If you have any short global variable names (1-2 characters), the --keep-globals option will probably shorten local (var) variables so that they conflict with the global variables.
The characters // may be treated as the start of a comment even if they are inside a string. To get around this, replace
var url = "http://site/page/";
var url = "http:/"+"/site/page/";
In addition to working well on Linux/Unix, this script has reportedly been able to run on Perl under Windows, though some Windows users report that it is better to remove the first line of this script file (#!/usr/bin/perl -wT)
Eric Hammond <firstname.lastname@example.org>