4

If I am using the Libraries API module to add a javascript library in my module, is it possible to have the library load in the footer instead of the header?

If not is there an alternative method?

1
1

Instead of running the libraries_load() function:

$library = libraries_load('easyzoom');

I just used the libraries_get_path() function to get the path and attached to the element and added scope of footer.

$easyzoom_library_path = libraries_get_path('easyzoom');

$element['#attached']['js'] = array(
  $easyzoom_library_path . '/dist/easyzoom.js' => array('scope' => 'footer'),
);
0

You can use scope parameter of drupal_add_js to specify the location of your script.

drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
    array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
  );

Follow this for more details and examples of drupal_add_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.