最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

http - When serving JavaScript files, is it safe to gzip it by default - Stack Overflow

programmeradmin0浏览0评论

The question fits in the title. I am not interested in what the spec remend but what the mix of browsers currently deployed support the best.

  • Google Docs gzips their JS.
  • The Google AJAX Libraries API CDN gzips JS.
  • Yahoo gzips the JS for their YUI files.
  • The Yahoo home page gzips their JS.

So I think that the answer to my question is yes, it is fine to gzip JS for all browsers. But you'll let me know if you disagree.

The question fits in the title. I am not interested in what the spec remend but what the mix of browsers currently deployed support the best.

  • Google Docs gzips their JS.
  • The Google AJAX Libraries API CDN gzips JS.
  • Yahoo gzips the JS for their YUI files.
  • The Yahoo home page gzips their JS.

So I think that the answer to my question is yes, it is fine to gzip JS for all browsers. But you'll let me know if you disagree.

Share Improve this question edited Mar 26, 2014 at 8:16 munity wiki
2 revs, 2 users 100%
avernet
Add a ment  | 

2 Answers 2

Reset to default 7

If you gzip your .js (or any other content), two problems may arise: 1. gzip increases the latency for unpressible files (needs time to press and unpress) 2. an older browser may not understand the gzipped content. To avoid problem 2, you should examine the Accept-Encoding and User-Agent or other parts of the HTTP request to guess if the browser supports gzip. Modern browsers should not have problems with gzippd content.

An excerpt from http://httpd.apache/docs/2.2/mod/mod_deflate.html: At first we probe for a User-Agent string that indicates a Netscape Navigator version of 4.x. These versions cannot handle pression of types other than text/html. The versions 4.06, 4.07 and 4.08 also have problems with depressing html files. Thus, we pletely turn off the deflate filter for them.

No, it's not. Firstly, the browser must declare that they accept gzip encoding as per Supercharging Javascript. On top of that, certain versions of IE6 have broken implementations, which is still an issue if they haven't been patched. More in The Internet Explorer Problem (with gzip encoding).

发布评论

评论列表(0)

  1. 暂无评论