0

mymodule.info:

name = custom
description = custom module

core = 7.x
version 7.x-0.1

scripts[] = custom.js

created the file custom.js in the same folder as custom.module file I have the $scripts variable in html.tpl.php cleared all caches

Still cannot see custom.js in page sources. What else it might be?

8
  • Your custom module is activated? Nothing shown in javascript console (with Firebug or Developer Toolbar)? Any watchdog errors?
    – Matt
    Mar 5 '14 at 16:00
  • Yes, it's activated. But there's no errors in console. Same with watchdog. Is it working at all? (i mean js file in info a module info file) Mar 5 '14 at 16:13
  • Yes it should work as stated here: drupal.org/node/542202#scripts. Maybe check file permissions and try to put a simple "drupal_set_message" into your module to check if it is well installed.
    – Matt
    Mar 5 '14 at 16:20
  • if i do drupal_add_js() inside my .module file it works, it's not working if i use it in info file. Mar 5 '14 at 16:22
  • Try removing the "version 7.x-0.1" line, as it is discouraged (drupal.org/node/542202#version) and it is not the right syntax (should be version = "7.x-0.1")
    – Matt
    Mar 5 '14 at 16:26
1

The problem is with a typo in the info file. It's missing a "=" on the version line. Correct info file here:

name = custom
description = custom module

core = 7.x
version = 7.x-0.1

scripts[] = custom.js

Also note that the version properties is discouraged

1
  • Version is only discouraged if your module is to be hosted on Drupal.org. If you've written a local module for a custom project/client -- then of course you want a version number.
    – tenken
    Mar 5 '14 at 17:47

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.