Posted 2001-11-11T14:40:00+01:00 in web
Javascript .js files that are often included in webpages these days can be gzip
encoded with the latest 5.* browser from Microsoft and Netscape. The 70kb
lib.js file that we are using in our JSP project, is reduced to 11kb as a
result. The trick is in spotting the right browser. You can’t just send the
gzip file to any browser that sends a HTTP Accept-encoding gzip
header. Older 4.0 browser really only decode the webpage itself, the included
javascript is left as-is: binary garbage. Making a JSP page that can do the
trick for you is even more difficult, but I did it anyway: encoder.jsp.
It was never taken into production because some MSIE 5.0 versions were capable of decompressing the .js file, whereas some other MSIE 5.0 browsers, with the same version number didn’t decompress. The difference between these browsers was in the hotfixes that were applied, but there’s no way of telling that from the HTTP headers or javascript browser API.