You can run your files with a script that will gzip them for you and add the appropriate expiration headers. Either configure the URL rewrite, or rewrite the URLs manually:
<script src="js/somescript.js"></script>
becomes
<script src="compress.php?somescript.js"></script>
and in compress.php you can do something like
<?php $file = 'js/' . basename($_SERVER['QUERY_STRING']); if (file_exists($file)) { header ('Last-Modified: ' . date('r',filemtime($file)); header ('Content-Type: text/javascript'); // otherwise PHP sends text/html, which could confuse browsers ob_start('ob_gzhandler'); readfile($file); } else { header('HTTP/1.1 404 Not Found'); }
Obviously, this can be expanded, as well as provide HTTP caching and / or on-the-fly viewing.
source share