June 6, 2007 updated: LZ77 JavaScript Compressor http://demo.java2script.org/lz77js/ is rebuilt using Java2Script Simple RPC technology.
Sep 4, 2006 updated: Please read “LZ77 JavaScript Compressor Reloaded“.
In compressing JavaScript, I prefer to dean.edwards.name/packer/. But the packer does not have a Java version. So some days ago I was thinking to write a similiar Java version of JavaScript packer, same as Dean’s packer.
But finally, a different JavaScript compressor came out. Its algorithm was based on the well-known LZ77, which is also the algorithm base of GZIP. Uncompressing of this method ran poor in Browser. It took about 2~4 seconds to uncompressing about 130k into 400k.
But when I integrate LZ77-JS-Compressor with Dean’s packer. It worked happily with about 4s+ lapse. In the practice, 400k JavaSource was zipped into 180k by Dean’s packer. And then 180k zipped JavaScript was compressed by my LZ77-JS-Compressor with result of about 100k of finaly scripts! It took about 1.5~2.5s uncompressed by my 1k uncompressor, and 0.5~1.5s unpacked with Dean’s packer, and finally 0.5~1.5s evaluating the script sources. Different browsers were performing differently in different periods.
Once the packer reaches the compressing ratio at about 33%. Now it comes out that 25% of compressing ratio! It saves about 80k more bytes from 180k sources. And now for 56K modemn it takes 100k * 8/56k + 3 ~ 19 seconds to load the whole pages. For those bandwidth it takes 1~4 seconds plus for the page! But infact, we always get our pages at poor speed.
Demo page with LZ77-JS-Compressor is here: http://j2s.sourceforge.net/swt/snippets/j2s-lz77.html
PS: The performance is worser than what I expect. For Firefox, it need about 4.5s to uncompress the script, which is acceptable. But for IE, it takes about 10s to initialize the script!
And each time, I go back or revisit the page, it requires the same times calculating and uncompressing!
OK, just take this as a way to uncompress text data.