Javascript Compression

The following utilities generate self-extracting archives for Javascript or HTML files. Ideal for situations when file size is critical. Because of the time required to compress even small files, about 10k is probably the upper limit for uncompressed files.

Before compressing, make sure all Javascript statements end with a semi-colon and any files to be compressed don't contain ` or ~ (these are special characters used by the compression mechanism). Remove comments, superfluous whitespace and newlines to create a single-line file. Applications like BrainJar's Crunchinator, Charles Foster's JS Cruncher, or DOMAPI's JSCruncher can save you the work by doing this for you.

Copy and paste your code into one of the textareas below and press the "Compress" button. The compression process will take a while (about 1 minute per 1k). You can watch it's progress in your browser's status bar. The resulting, compressed file is a self-extracting archive that, when viewed in a browser, will uncompress and run itself. The compression mechanism looks for repeated strings and substitutes tokens for those strings (up to 62 substitutions can be made). You can set a maximum string replacement length - lower values will speed compression but may not optimally compress your file. Because the self-extraction code is added to the compressed code, some pre-optimized, sub-1k files will grow in size when run through the compressor.

For Javascript Only

Either .js files or the content of <script> script tags.

Small Files (1k or less)

Copy and paste your code here:

Max replacement string length:


Compressed code:

Compressed size: bytes

Larger Files (greater than 1k)

Copy and paste your code here:

Max replacement string length:


Compressed code:

Compressed size: bytes

For HTML Documents

Full HTML documents including internal and external scripts, stylesheets, etc.

Copy and paste your code here:

Max replacement string length:


Compressed code:

Compressed size: bytes

Related Items