Step 1: Add the gzip.php file.
Then add it to the root directory of your website.
Step 2: Adjust your HTML.
<link href="gzip.php?f0=css/main.css" rel="stylesheet" type="text/css">
To change the address of the scripts just change the address that is in italic. Files are restricted to only files with the .css or .js extension.
Step 3: Merging Files.
<link href="gzip.php?f0=css/main.css&f1=css/more.css&f2=css/evenmore.css" rel="stylesheet" type="text/css">
NOTE: Make sure you don’t miss any numbers when counting up otherwise it won’t include all your files.
Step 4: Caching Files.
Another trick that will help speed up your site is caching these files. Again I have that covered! Simply add cache=true& to the front of the file address as follows…
If you don’t want to have the default 3 days expiry you may add in exp=#ofDays& and it will change the expiry period. For example the following will set the cache period to 31 days…
NOTE: It is not recommended that you cache files that are updated frequently as when the file is updated it won’t update in the browser for the number of days you set.
And there you have it! I have decreased loading time on my sites dramatically using this exact script so I hope it helps you out as much as it has with me!
UPDATE: Just released version 1.1.1 which adds new functionality and better ways to pinpoint errors. Release Notes.
UPDATE: Just released version 1.1 which fixes a security hole (thanks for the heads up Nail) as well as a number of other minor updates. Release Notes.