JSTrim

Documentation

Basic example

Compresses test1.js to test1_compressed.js using default low method.

jstrim test1.js test1_compressed.js

Pack example (better compression)

Compresses test1.js to test1_compressed.js using the Dan Edvards algoritm. That algoritm might be a bit slow to unpack for the browser on larger scripts so thats why TinyMCE doesn't use that method.

jstrim --mode high test1.js test1_compressed.js

Batch process using an config file

Performs a batch compression using the specified config file.

 jstrim --config ..\conf\simple_example.config

Batch process using an config file and forcing update

Performs a batch compression using the specified config file and forces update on all files. JSTrim checks the modification date of the files by default so it will skip processing unmodified source files. But if you for example switch compression method you might want to force an update.

jstrim --force --config ..\conf\simple_example.config

Example of a preprocessor instruction in a JS file

JSTrim can handle preprocessor like intructions to include/exlude parts of a JavaScript duing the compression process. This can be useful when you want to remove debugging logic in the build process.

JavaScript file

// #if var1

// This part will be included if the var1 is defined
someDebugCall();

// #endif

// #if !var2

// This part will be included if the var2 is undefined
someOtherCall();

// #endif

Command line call

jstrim -d var1,var2 src.js out.js

More documentation and examples can be found in the download package.