Delivering Pre-Compressed (gzip) Javascript with PHP only

There are plenty of results in Google for delivering compressed Javascript files using PHP.  However, most of those techniques involve compressing the JS file(s) on the fly. I was looking for a method that would meet the following criteria: The JS file should be pre-compressed using gzip. The gzip version of the JS file should only be delivered if the client’s browser supports gzip. The code below has some pitfalls: It will not work with a CDN or any external content server that does not support PHP. It is more difficult to maintain than compressing on the fly at the web server level (as you must maintain the compressed version of the JS file. I’ll use my quick and dirty … Continue reading