Skip to content

Instantly share code, notes, and snippets.

@pierrenel
Last active December 18, 2015 00:38
Show Gist options
  • Save pierrenel/5697560 to your computer and use it in GitHub Desktop.
Save pierrenel/5697560 to your computer and use it in GitHub Desktop.
Adding other javascript to it's own variable, and getting Drupal to aggregate it nicely on cache refresh.
<?php print $footer_js; ?>
<?php
function pilsner_init() {
$theme_path = drupal_get_path('theme', 'pilsner');
$js_files = array(
'libs/jquery.js',
'libs/handlebars.js',
'libs/jquery.easing.js',
'libs/jquery.infinitescroll.js',
'libs/jquery.mousewheel.js',
'libs/jquery.validate.min.js',
'libs/jquery.flexslider.js',
'libs/swfobject.js',
'nation/Utils.js',
'nation/EventDispatcher.js',
'nation/VerticalScrollbar.js',
'pilsner/website/models/global/WebsiteEvents.js',
'pilsner/website/views/HeaderView.js',
'pilsner/website/views/ArticleView.js',
'pilsner/website/views/ContentGridView.js',
'pilsner/website/views/AgeGateView.js',
'pilsner/website/views/FormView.js',
'pilsner/website/views/TermsView.js',
'pilsner/website/views/common/ExpandingList.js',
'pilsner/website/views/common/ExpandingContent.js',
'pilsner/website/views/common/Dropdown.js',
'pilsner/website/views/common/YouTubeVideoPlayer.js',
'pilsner/js/libs/googlemaps.infobox.js',
'pilsner/website/controllers/MainController.js'
);
foreach($js_files as $j) {
drupal_add_js($theme_path.'/js/'.$j, array('type' => 'file', 'scope' => 'footer_js', 'preprocess' => true));
}
<?php
function pilsner_preprocess_html(&$variables) {
$variables['footer_js'] = drupal_get_js($scope = 'footer_js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment