function hook_js_alter

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Render/theme.api.php \hook_js_alter()
  2. 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_js_alter()
  3. 10 core/lib/Drupal/Core/Render/theme.api.php \hook_js_alter()
  4. 11.x core/lib/Drupal/Core/Render/theme.api.php \hook_js_alter()

Perform necessary alterations to the JavaScript before it is presented on the page.


$javascript: An array of all JavaScript being presented on the page.

See also




Related topics

2 functions implement hook_js_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

locale_js_alter in modules/locale/locale.module
Implements hook_js_alter().
simpletest_js_alter in modules/simpletest/simpletest.module
Implements hook_js_alter().
2 invocations of hook_js_alter()
ajax_render in includes/
Renders a commands array into JSON.
drupal_get_js in includes/
Returns a themed presentation of all JavaScript code for the current page.


modules/system/system.api.php, line 746


function hook_js_alter(&$javascript) {
    // Swap out jQuery to use an updated version of the library.
    $javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.