1

How can I allow my module (created with Features) to add a new script to the head?

The script should be in the correspoinding module directory.

1

You can add a script using drupal_add_js and to have it added on every page, you can call it in hook_init.

Module directory path can be resolved by drupal_get_path('module', 'module_name')

module_init() {
  drupal_add_js(drupal_get_path('module', 'module_name')."/js/myscript.js");
}

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.