Compressing using the YUI Compressor is quite straight forward:
java -jar "yuicompressor-2.4.2.jar" --type js -o "file.compress.js" "file.js" java -jar "yuicompressor-2.4.2.jar" --type css -o "file.compress.css" "file.css"
Here, file.compress.js and file.compress.css are the compressed output files and file.js and file.css are the input files. These compressed files will work exactly like the original ones. So, you can simple replace the originals with these new compressed files and immediately start seeing faster page load times.
Combining multiple files into one file
Please note that this technique of combining files can end up requiring the user to download a large .js and .css file for each page if each page requires a different set of files. In that case, you might want to use this technique for only the core files that are required on each page or most pages.
Serve gziped files via PHP
Now that we have reduced the size and number of files considerably, we can further reduce the size by serving gzip content. If you use mod_gzip on apache, you might already be serving gziped files. However, you might still wish to use this section as compressing content on the fly with gzip might be slower than this technique.
We will first need to gzip the contents of the combined file from the previous step. Lets assume the file was file.js and the gzip compressed file is file.js.gz.
This file needs to be served through a PHP file. You can use the PHP code below to serve this file.
These steps should improve the page load time of your page considerably.