I am using bootstrap 3.6 sub-theme/cdn, I've added scripts[] = js/custom.js and I can see it in the source code of the page.

But... javascript is not working. I copied some javascript code modules to test and from my custom.js and still does not work.

how I can run my code javascript in my sub?

  • 1
    Welcome to Drupal Answers! What do you mean by is not working? Does it output anything?
    – apaderno
    Commented Jun 22, 2016 at 6:16

1 Answer 1


To put a JavaScript in your theme you must do the following steps:

Assuming that your sub-theme name is example.

  1. Update your example/example.info to have this scripts[] = js/custom.js. That means the custom.js path is example/js/custom.js.
  2. Clear the cache.


If your code in custom.js is not working then there is something wrong. First, check if there is a js error using browser console. Second, check the http response code make sure that there is no permission issue.

Alternative way to add Javascript.

Another way of adding Javascript is by using drupal_add_js. With this API you can control which page the js is going to load.

  • But why duplicate the javascript already in the bootstrap base theme? A sub-theme should be able to re-use code from its parent/base. Commented Sep 24, 2018 at 14:02

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