If I used gzipped JavaScript files, I get illegal character/token errors in both Chrome and Firefox
The webserver needs to tell the browser that the content is gzipped. This is done using the content-encoding header. Maybe you can configure your webserver to supply this header with files ending in .gz.
Instead of compressing the files statically, it is also common for the webserver to have functionality to compress documents on-the-fly. This means that you put the normal foo.js file in the document root, and configure the webserver to compress it when sending it to the client.
I had similar kind of error. Check in the network tab corresponding to your foo.js. In response header, the requested header should have Content-Encoding:gzip and Content-Type:application/javascript. Otherwise, browser will not decompress your file. Browser should know what kind of content encoding is done over the file.
This error can also occur if your gzip setting is too high. I've tried gzip -9
and even when sending the correct Content-Encoding, i got this error. When I just ran a regular gzip, via gzip file.js
, it then works correctly.