views:

236

answers:

2

The question fits in the title. I am not interested in what the spec recommend 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.

+5  A: 

If you gzip your .js (or any other content), two problems may arise: 1. gzip increases the latency for uncompressible files (needs time to compress and uncompress) 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.org/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 compression of types other than text/html. The versions 4.06, 4.07 and 4.08 also have problems with decompressing html files. Thus, we completely turn off the deflate filter for them.

pts
+5  A: 

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

cletus