Powered by Java2Script
org.java2script.demo.lz77jscompressor.LZ77JSCompressor

LZ77 is known as the basic loseless data compression algorithm. It is used very wide. For example, common *.png, *.zip, *.gzip, *.jar, *.war file formats use LZ77 compressing algrightm.

Here is a Java implementation of such LZ77 algorithm. And by using the Java2Script Simple RPC technology, it sends the string, which is going to be compressed, back to server, which is a Java Serlvet container, and the server runs LZ77 algorithm to compress given string, and then packs compresed string back to browser side. As this compression is specially designed for JavaScript sources, it gives options for how JavaScript codes are compressed. In most cases, this compressor compresses JavaScript at the ratio of 40%~60%. And if you check off those JavaScript options, this compressor can compress any given string.

For more details about LZ77 algorithm, you may check here.

You can test this compressor on latest Prototype.js, it will compress 70k to 33k (48%) without "RegEx trimming before LZ77" option (loseless, comments left). If with "RegEx trimming before LZ77" option on, there will be compressed to 28k (40%). If Prototype.js is compressed by native compressor, like 7-Zip, it will be 16k (24%).

Other well-known JavaScript compressors:

For more discussion, please visit LZ77 JavaScript Compressor Reloaded.

--
Zhou Renjian
June 4, 2007 (Last updated: November 22, 2009)

>> Add to del.icio.us
>> Stumble it