hook_js_alter(&$javascript, \Drupal\Core\Asset\AttachedAssetsInterface$assets)
Perform necessary alterations to the JavaScript before it is presented on the page.
$javascript: An array of all JavaScript being presented on the page.
\Drupal\Core\Asset\AttachedAssetsInterface $assets: The assets attached to the current response.
\Drupal\Core\Asset\AssetResolver
function hook_js_alter(&$javascript, \Drupal\Core\Asset\AttachedAssetsInterface $assets) { // Swap out jQuery to use an updated version of the library. $javascript['core/assets/vendor/jquery/jquery.min.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js'; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_js_alter/8.1.x