Huy Dinh

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:

minify.zip

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.

:,

1 Comment for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!