function drupal_add_library

cis7 drupal_add_library($module, $name, $every_page = NULL)
cle7 drupal_add_library($module, $name, $every_page = NULL)
elmsmedia7 drupal_add_library($module, $name, $every_page = NULL)
icor7 drupal_add_library($module, $name, $every_page = NULL)
meedjum_blog7 drupal_add_library($module, $name, $every_page = NULL)
mooc7 drupal_add_library($module, $name, $every_page = NULL)

Adds multiple JavaScript or CSS files at the same time.

A library defines a set of JavaScript and/or CSS files, optionally using settings, and optionally requiring another library. For example, a library can be a jQuery plugin, a JavaScript framework, or a CSS framework. This function allows modules to load a library defined/shipped by itself or a depending module, without having to add all files of the library separately. Each library is only loaded once.


$module: The name of the module that registered the library.

$name: The name of the library to add.

$every_page: Set to TRUE if this library is added to every page on the site. Only items with the every_page flag set to TRUE can participate in aggregation.

Return value

TRUE if the library was successfully added; FALSE if the library or one of its dependencies could not be added.

See also




33 calls to drupal_add_library()
back_to_top_init in sites/all/modules/ulmus/back_to_top/back_to_top.module
Implementation of hook_init Add javascript & css but first check if prevent on mobile
back_to_top_settings in sites/all/modules/ulmus/back_to_top/
better_exposed_filters_exposed_form_plugin::exposed_form_alter in sites/all/modules/ulmus/better_exposed_filters/
Tweak the exposed filter form to show Better Exposed Filter options.
boxes_add_js in sites/all/modules/ulmus/boxes/boxes.module
Add JavaScript to the page.
context_reaction_block::editor_form in sites/all/modules/ulmus/context/plugins/
Context editor form for blocks.

... See full list

1 string reference to 'drupal_add_library'
overlay_render_region in modules/overlay/overlay.module
Renders an individual page region.


includes/, line 4694
Common functions that many Drupal modules will need to reference.


function drupal_add_library($module, $name, $every_page = NULL) {
  $added = &drupal_static(__FUNCTION__, array());

  // Only process the library if it exists and it was not added already.
  if (!isset($added[$module][$name])) {
    if ($library = drupal_get_library($module, $name)) {
      // Add all components within the library.
      $elements['#attached'] = array(
        'library' => $library['dependencies'],
        'js' => $library['js'],
        'css' => $library['css'],
      $added[$module][$name] = drupal_process_attached($elements, JS_LIBRARY, TRUE, $every_page);
    else {
      // Requested library does not exist.
      $added[$module][$name] = FALSE;

  return $added[$module][$name];



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.