3

How do I remove js from a specified page?

templates.php enter image description here

  • Please post code as a code block, not as an image. And using drupal_add_js should be the last way, least preferable. They should be #attached to renderable array - then you can operate on them easily. – Mołot Dec 12 '13 at 14:00
11

You can use hook_js_alter()

function MYTHEME_js_alter(&$javascript) {
  if ($some_condition) {
    unset($javascript['path/to/script.js']);
  }
}
  • function newyasi_js_alter(&$javascript) { if (current_path() == 'node/89') { unset($javascript['sites/all/themes/js/jquery.carouFredSel-6.2.1-packed.js']); } } – benneng Dec 12 '13 at 14:16
  • Fatal error: Cannot redeclare newyasi_js_alter() (previously declared in D:\WWW\newyasi\sites\all\themes\newyasi\template.php:136) in D:\WWW\newyasi\sites\all\themes\newyasi\template.php on line 289 – benneng Dec 12 '13 at 14:16
  • 2
    You have the same function at line 136 and line 289 of the template.php file. You have to remove one of them. – rooby Dec 12 '13 at 14:21

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.