Zip.js - A JavaScript library to zip and unzip files
gildas-lormeau.github.com
gildas-lormeau.github.com
I used it a week ago for a simple project (a kinda secure file system - with PHP and MongoDB for backend). I would encrypt a file on my server (AES) and then send the encrypted data to user's browser. Then I could decrypt the data with JavaScript and used JSZip to make user's browser download the decrypted files.
https://mail.mozilla.org/pipermail/es-discuss/2012-January/0...
Here is the zip output http://dl.dropbox.com/u/9694286/zip.js/123Example.zip
And finally the guilty upload http://dl.dropbox.com/u/9694286/zip.js/search-engine-optimiz...
Hope it helps debug or something!
[1] http://gildas-lormeau.github.com/zip.js/demos/demo2.html
LZMA is nice for streaming data to many clients (i.e. compress once, decompress many times), because although compression time/CPU is high (LZMA > BZIP2 > GZIP), compression ratio is very good (LZMA > BZIP2 > GZIP) and decompression not too bad (BZIP2 > LZMA > GZIP) [2].
[1] http://code.google.com/p/js-lzma/
[2] Disclaimer: I should check, but haven't yet, whether these inequalities hold for this JS LZMA implementation relative to the available GZIP and BZIP2 ones.
I don't know about this library in particular, but there's some numbers available on http://liblzg.bitsnbites.eu/ for a similar library.
(The same author has also made a library for self extracting javascript code: http://crunchme.bitsnbites.eu/. Pretty cool, but probably not that useful outside of the demo scene.)
Using zip 3.0:
$ time zip logfile.zip logfile.log
adding: logfile.log (deflated 89%)
real 0m1.170s
user 0m0.947s
sys 0m0.030s
Resulting file size: 4,551,020 bytesUsing Chrome 16.0.912.77:
4.7s - 1st drop
5.5s - 2nd drop
5.2s - 3rd drop
5.1s - 4th drop
Average 5.125s
(timed using stopwatch)
Resulting file size: 4,547,885 bytesSize: Advantage Zip.js by 3,135 bytes (roughly 3k; 6.8% better than zip) Speed: Advantage zip by 3.955s (77% better than Zip.js)
Your calculation of 6.8% better than zip just seemed too impressive.
Showing the math:
zip = 4,551,020
zipjs = 4,547,885
diff = zip - zipjs => 3,135 bytes
pctng_diff = diff/zip × 100 => 0.0688856564%