JavaScriptZip is a JavaScript compressor. It removes all comments and unnecessary spaces from the source file.
Some additional optimizations are also performed (wich may be disabled using the disableOptimizations
property):
new Object()
is replaced by {}
new Array(el1, el2, ...)
is replaced by [el1, el2, ...]
. When a single numeric argument is passed, the number is not an element, but the initial capacity. On this case, the optimization is not donenew RegExp("exp", "flags")
is replaced by /exp/flags
It's written in Java, so you need Java on your system. Java 1.4 or greater is required. If you don't have it, download here.
There are two forms to run JavaScriptZip: via a shell script or Ant task.
The script may be runned from <JAVASCRIPTZIP_HOME>/bin
directory, or the JAVASCRIPTZIP_HOME environment variable may be set, where it could be runned from any directory.
On Windows the script is called javascriptzip.bat
. On UNIX, javascriptzip.sh
.
These are the arguments:
javascriptzip [options] INPUT OUTPUT
, Where:
To run the Ant task, you must first define the task using the taskdef
task:
<taskdef name="javascriptzip" classname="net.sf.javascriptzip.JavaScriptZipTask" classpath="Path to javascriptzip.jar"/>
Then, use the task itself:
<javascriptzip srcFile="src.js" destFile="dest.js" header="This is the header text"/>
Here are all possible attributes:
true
, will disable the additional optimizationsOne of srcFile and srcDir must be informed. When srcFile, one of destFile or destDir must be informed. Otherwise, srcDir is mandatory. The rest are optional.
To check the JavaDocs, take a look here