function AssetResolverInterface::getJsAssets

Same name in other branches
  1. 9 core/lib/Drupal/Core/Asset/AssetResolverInterface.php \Drupal\Core\Asset\AssetResolverInterface::getJsAssets()
  2. 8.9.x core/lib/Drupal/Core/Asset/AssetResolverInterface.php \Drupal\Core\Asset\AssetResolverInterface::getJsAssets()
  3. 10 core/lib/Drupal/Core/Asset/AssetResolverInterface.php \Drupal\Core\Asset\AssetResolverInterface::getJsAssets()

Returns the JavaScript assets for the current response's libraries.

References to JavaScript files are placed in a certain order: first, all 'core' files, then all 'module' and finally all 'theme' JavaScript files are added to the page. Then, all settings are output, followed by 'inline' JavaScript code. If running update.php, all preprocessing is disabled.

Note that hook_js_alter(&$javascript) is called during this function call to allow alterations of the JavaScript during its presentation. The correct way to add JavaScript during hook_js_alter() is to add another element to the $javascript array. See locale_js_alter() for an example of this.

Parameters

\Drupal\Core\Asset\AttachedAssetsInterface $assets: The assets attached to the current response. Note that this object is modified to reflect the final JavaScript settings assets.

bool $optimize: Whether to apply the JavaScript asset collection optimizer, to return optimized JavaScript asset collections rather than an unoptimized ones.

\Drupal\Core\Language\LanguageInterface $language: (optional) The interface language for the assets will be rendered with.

Return value

array A nested array containing 2 values:

  • at index zero: the (possibly optimized) collection of JavaScript assets for the top of the page
  • at index one: the (possibly optimized) collection of JavaScript assets for the bottom of the page
1 method overrides AssetResolverInterface::getJsAssets()
AssetResolver::getJsAssets in core/lib/Drupal/Core/Asset/AssetResolver.php
Returns the JavaScript assets for the current response's libraries.

File

core/lib/Drupal/Core/Asset/AssetResolverInterface.php, line 86

Class

AssetResolverInterface
Resolves asset libraries into concrete CSS and JavaScript assets.

Namespace

Drupal\Core\Asset

Code

public function getJsAssets(AttachedAssetsInterface $assets, $optimize, ?LanguageInterface $language = NULL);

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