Can I compress data in JavaScript?

烈酒焚心 提交于 2019-11-30 03:57:30

问题


I'm using some pretty heavy AJAX with lots of data going from client to server. How can I compress the data (mostly plain text) before sending to the server?

And how can I uncompress the data on the server side?


回答1:


jSEND seems to do EXACTLY this. Anyone ever use it?

Broken link removed: led to spam landing page @ jsend.org




回答2:


The jsolait library has a codec that supports the LZW algorithm (among others, including base64 encoding/decoding). The only thing that makes me a little hesitant is that this library is no longer being actively maintained.

EDIT

I was able to find a few more implementations of the LZW algorithm in Javascript.




回答3:


Using LZW compression:

client site: http://jsfiddle.net/sebastienp/p7kDe/

server site: http://webdevwonders.com/lzw-compression-and-decompression-with-javascript-and-php/



来源:https://stackoverflow.com/questions/6127818/can-i-compress-data-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!