admin管理员组

文章数量:1415111

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).

本文标签: httpWhen serving JavaScript filesis it safe to gzip it by defaultStack Overflow