Software engineer, data guy, Open Source enthusiast, New Hampshire resident, husband, father. Fan of guitars, hiking, photography, homebrewing, sarcasm.
Drupal 5: Minify and aggregate all javascript files to increase page load time performance
Adding this code to your Drupal site can improve two sections of a YSlow report, “Make fewer HTTP requests” and “Minify JS”. This function minifies and aggregates your javascript into a single file. It requires the Google code library jsmin-php (http://code.google.com/p/jsmin-php/).
Stick this function in your template.php file in your theme directory:
In your page.tpl.php theme file, replace this line:
with:
You can also improve your score in the “Put JS at the bottom” section by ensuring this line of code resides at the bottom of your page.tpl.php file. I insert it just before this line: