1

Some modules insert JavaScript at top of list. I put my $sctipts variable at the bottom of html.tpl.php file just before the closing of body tag. Due to this, some scripts do not work as they get called before jquery or drupal.js . Please provide steps to reorder list of js. I tried this code in my template.php but with no effect:

function MYTHEME_js_alter(&$javascript) {
  $javascript['sites/all/modules/syntaxhighlighter/syntaxhighlighter.min.js']['group'] = 500;
  $javascript['sites/all/modules/syntaxhighlighter/syntaxhighlighter.min.js']['weight'] = 500;
}

Solved. I did this: enabled AdvAgg Modifier, Advanced CSS/JS Aggregation. Then I visited settings page /admin/config/development/performance/advagg/mod where I checked options: Enable preprocess on all JS, Move all inline scripts to the bottom of the execution order, Move all browser conditional JavaScript to the bottom of the group, Move JS to the footer - All. And now i have all JS in the bottom (as google recommends), without need to chane html.tpl.php

  • drupal.org/project/advagg should be able to do what you're wanting to do. – mikeytown2 Jun 15 '15 at 21:48
  • 1
    thank you! it helped me to optimize my site without any errors. So i did this: enabled AdvAgg Modifier, Advanced CSS/JS Aggregation. Then I visited settings page /admin/config/development/performance/advagg/mod where I checked options: Enable preprocess on all JS, Remove unused JavaScript if possible, Move all inline scripts to the bottom of the execution order, Move all browser conditional JavaScript to the bottom of the group, Move JS to the footer - All. And now i have all JS in the bottom (as google recommends), without need to chane html.tpl.php. GREAT! – tlito Jun 15 '15 at 22:04
  • @tlito It'd be great if you could write that comment up as an answer, maybe help some people with the same problem in the future :) – Clive Jun 15 '15 at 23:18
  • @tlito - please help others out by posting your solution as an answer, as Clive suggested. Otherwise this post will remain as unanswered forever. – othermachines Aug 24 '15 at 6:34
0

Solved. I did this: enabled AdvAgg Modifier, Advanced CSS/JS Aggregation. Then I visited settings page

/admin/config/development/performance/advagg/mod

where I checked options:

  • Enable preprocess on all JS,

  • Move all inline scripts to the bottom of the execution order,

  • Move all browser conditional JavaScript to the bottom of the group,

  • Move JS to the footer - All.

And now i have all JS in the bottom (as google recommends), without need to chane html.tpl.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.