Javascript Aggregator

Javascript Aggregator

This module adds a simple .js aggregation to Drupal 5.x.

It increases the performance of your site with less server requests per pageload. Especially in shared hosting environments this can be a huge boost.

This approach requires NO core-patching.

To fix problems with some modules like TinyMCE edit the discard list at admin/settings/performance

It basically does the following:

  • takes the $scripts variable and removes .js files using a regular expression
  • generates a unique filename for any set of .js files
  • creates and caches one file containing all .js files in files/js
  • returns a modified $srcipts variable with link to cached file

To aggregate .js files

  1. enable the module
  2. go to admin/settings/performance and enable the js cache (you'll also find an option to clear js cache)
  3. place the following code inside your page.tpl.php file just before <?php print $scripts; ?>

<?php
 
if(module_exists('javascript_aggregator')) {
   
$scripts = javascript_aggregator_cache($scripts);
  }
?>

Its not good practice however to place php code in your tpl.php files. If you are more familiar with drupal, USE THIS WAY TO CALL THE FUNCTION:
http://drupal.org/node/218870#comment-721082

Comments welcome.

Developement sponored by: http://iwanttospeak.net

Releases

Official releasesDateSizeLinksStatus
5.x-1.32008-Apr-198.89 KBRecommended for 5.xThis is currently the recommended release for 5.x.
 
 

Drupal is a registered trademark of Dries Buytaert.