I just added a script scroll.js, but it does not get loaded.

My theme is called test. I put the script in the js directory within the theme directory.

Permissions on the script are 644 (like on all other scripts in other themes) and permissions on the js directory are 755.

I added a line scripts[]= js/scroll.js to test.info.

Sorry for forgetting to mention the version of Drupal. I'm using Drupal 7. I flushed all caches and did a hard refresh in the browser (tried both Firefox and Chromium).

After it looking like nothing was being loaded, I added a line window.alert("sometext"); to the script just to be sure. Still nothing.

In Firefox and Chrome the file is neither listed as being loaded nor as failing to load or permissions error.

It seems to me that the change to the .info file is being ignored, but I might well be wrong. How do I force Drupal to not ignore the new script file?

  • The answer is different based on whether you are using Drupal 7 or Drupal 8, you mention the .info file so assuming you are on D7?
    – Duncanmoo
    Feb 20 '18 at 13:50
  • Would re-installing your theme help? In my experience this was solved by a simple drupal cache clear.
    – Beebee
    Feb 20 '18 at 14:11

In drupal 8 my theme uses the file main.js. If my theme was called test I would add the file in this order.

File location:


In test.info.yml:

  - test/global-js
  - test/global-css

In libraries.yml:

    js/main.js: {}
      css/styles.css: {}

Remember your spacing in the .yml files (2 spaces).
also read adding stylesheets and javascript to a drupal 8 theme and
Creating a drupal 8 sub-theme, or sub-theme of sub-theme

Happy Drupaling

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.