Search code examples
javascripthttpgzipcontent-encoding

When serving JavaScript files, is it safe to gzip it by default


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.


Solution

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