javascript文本压缩/解压缩 [英] javascript text compression/decompression

查看:195
本文介绍了javascript文本压缩/解压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个400K的文本文件,我想从一个javascript中读取。问题是,我的目标受众有一个缓慢的连接,所以400k可能需要太长时间加载。

Suppose I have a 400K text file which I want to read from a javascript. The problem is, my target audience have a slow connection, so 400k might take too long to load.

我想我需要压缩文件,但是,

I suppose I need to compress the file, but well, how can I decompress it via javascript on the client side?

这是否值得吗,还是减压需要的时间否定下载时保存的时间?

Is it worth it, or will the time needed for decompression negate the time saved in downloading?

UPDATE

为了清楚起见,文件是文本(数据)而不是代码。 >

Just to be clear, the file is text (data) not code.

推荐答案

可以 GZip 文本文件,并将其发送到浏览器。这样,你不必在客户端做任何事情,浏览器本身会解压缩它。

You can GZip the text file, and sent it to the browser. That way you wont have to do anything on the client side, the browser itself will decompress it.

这篇关于javascript文本压缩/解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆