Is there a library available for compression in Javascript

gkaykck picture gkaykck · Feb 27, 2011 · Viewed 9.7k times · Source

I am looking for sending data from server in a compressed format to client(with ajax requests), and than decompress that data with a browser? Is there a library for this?

I am not looking for compressing javascript files!

EDIT: I think question was not clear enough, i don't want to compress html files, i want to store some compressed LZMA files or any other compression format on server(like an obj file), and then i need to decompress them after i got it with AJAX. Not simultaneous compression/decompression with gzip. Opening already zipeed files after getting them with Javascript.

Answer

Chris Farmiloe picture Chris Farmiloe · Feb 27, 2011

Your web-server (and the browser) should be capable of handling this transparently using gzip. How this is setup will depend on which server you are using.

Checkout mod_deflate in apache or enabling gzip in nginx.

The browser will automatically decompress the data before it reaches your XHR handler and you can be safe in the knowledge that your data was compressed as much as possible in transit.