Created
June 19, 2012 08:14
-
-
Save opi/2952956 to your computer and use it in GitHub Desktop.
Extreme Drupal JS aggregation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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