Minify Magento’s JS and CSS
by Huy Dinh on Aug.31, 2008, under PHP
I don’t want to sound like a broken record but Magento is slow. So why then aren’t the JS and CSS minified by default?
My love for optimisation knows no boundaries, as such, I’ve taken it on myself to provide an automated solution – here it is:
It’s a simple script that scans through each theme’s layout/page.xml and minifies each JS and CSS it finds.
To use the script, you need to have the Java runtime environment installed, php must have shell execution abilities and your webserver must have write permissions inĀ each theme’s page.xml (/app/design/frontend/default/default/layout/page.xml), css folder (/skin/frontend/default/default/css) and the main js folder (/js). You also need to have YUI Compressor’s build jar file on your server (download it here).
One last thing is to edit the script with your Magento’s root folder and location of YUI Compressor’s jar file.
It is recommended that you put the script into a password protected folder!
Oh, one last thing: I haven’t tested the script in a Windows environment so it may not work.





October 13th, 2008 on 10:59
Hey Huy,
Thought I just drop you a line here to bring to your attention our extension. It minifies Magento files on the fly:
http://www.magentocommerce.com/extension/457/fooman-speedster
looking forward to your feedback