Is there a library available for compression in Javascript

I'm looking for sending data from a server in a compressed format to a client (using ajax requests) and then unpacking this data in a browser? Is there a library for this?

I am not looking for javascript file compression!

Thanks...

EDIT: I think the question was not clear enough, I do not want to compress html files, I want to store LZMA compressed files or any other compression format on the server (for example, obj file), and then I need to unzip them after I received him with ajax. Not simultaneous compression / decompression using gzip. Opening already zipeed files after receiving them with Javascript.

+7
source share
5 answers

Your web server (and browser) should work with this transparently using gzip. How this setting will depend on which server you are using.

Checkout mod_deflate in apache or enable gzip in nginx.

The browser will automatically decompress the data before it reaches your XHR handler, and you can be safe knowing that your data has been compressed as much as possible along the way.

+6
source

I know this is a very late answer, but I found this interesting alternative: http://pieroxy.net/blog/pages/lz-string/index.html It also has implementations in other languages!

And my favorite is pako now. It is really fast and easy to use and compatible with the well-known zlib

+3
source

This looks promising: http://code.google.com/p/jslzjb/

0
source

What Eric said, http://code.google.com/p/jslzjb/

Here is some basic code to help you figure out and decode.

var stringStreamIn = function(s) { this.data = s; this.length = this.data.length; this.offset = -1; this.readByte = function(){ if (++this.offset >= this.length) { return null; } return this.data.charCodeAt(this.offset); }; }; var stringStreamOut = function() { this.data = ''; this.length = function() { return this.data.length; }; this.writeByte = function(value) { this.data += String.fromCharCode(value); }; }; var so = new stringStreamOut(); var si = new stringStreamIn(atob("XQAAgAD//////////wAnG8AHA8+NCpYMj8Bgfez6bsJh4zoZx3fA+gih10oOa6rwYfkaucJIKX8T69I5iOe8WJwg/Ta7x3eHeDomxR6Vf824NLmKSrWHKdnM9n0D2aipzLbHv5//sTGAAA==")); LZMA.decompressFile(si, so); console.log(so.data); 
0
source

I put LZMA on the GWT some time ago. If you use GWT, this may be a viable option.

https://code.google.com/p/gwt-lzma/

0
source

All Articles