Created
April 18, 2012 05:43
-
-
Save pixelwhip/2411333 to your computer and use it in GitHub Desktop.
This is simple alter function I had to write while addressing an issue on the DrupalCon site. It led to this blog post. http://pixel-whip.com/blog/12/03/all-cool-kids-back-bus
This file contains 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() | |
*/ | |
function shizzle_js_alter(&$javascript) { | |
// Collect the scripts we want in to remain in the header scope. | |
$header_scripts = array( | |
'sites/all/libraries/modernizr/modernizr.min.js', | |
); | |
// Change the default scope of all other scripts to footer. | |
// We assume if the script is scoped to header it was done so by default. | |
foreach ($javascript as $key => &$script) { | |
if ($script['scope'] == 'header' && !in_array($script['data'], $header_scripts)) { | |
$script['scope'] = 'footer'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment