Skip to content

Instantly share code, notes, and snippets.

@opi
Created June 19, 2012 08:14
Show Gist options
  • Save opi/2952956 to your computer and use it in GitHub Desktop.
Save opi/2952956 to your computer and use it in GitHub Desktop.
Extreme Drupal JS aggregation
<?php
/**
* Implements hook_js_alter().
* Force every JS file on every_page in the same group, in order to have only one aggregated file, and reduce http requests.
*/
function YOURTHEME_js_alter(&$js) {
foreach($js as $file => $info) {
if ($info['type'] == 'file') {
$js[$file]['every_page'] = TRUE;
$js[$file]['group'] = JS_THEME;
$js[$file]['weight'] = $info['weight']+ $info['group'];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment