I installed the Chosen module and it is conflicting with my JavaScript code. That module gets loaded on every page, even if there is no select box on the page. It is definitely unnecessary to load the files from that module when they are not necessary at all.

What I want to do is modifying the module to only load on certain pages.

How should I go about doing this? What function do I have to call or look for within that module?

1 Answer 1


You should use hook_js_alter() within template.php

function yourthemename_js_alter(&$javascript) {
  if ('this is true') {

I'm wondering if either solution will result in caching issues though. If I may: I would first try to figure out why my JavaScript collides with the module and fix it there.

You can also use the hook within a custom module if you already have one that relates to what you're trying to accomplish here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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