Libraries have the ability to specify other libraries as dependencies. This allows Drupal to provide a minimum footprint on the fronted performance.
jQuery is only loaded if a JavaScript library specifies it as a dependency.
Refer to https://www.drupal.org/node/1541860
Here's an example from the Quick Edit module's libraries.yml file:
quickedit:
version: VERSION
js:
...
css:
...
dependencies:
- core/jquery
- core/jquery.once
- core/underscore
- core/backbone
- core/jquery.form
- core/jquery.ui.position
- core/drupal
- core/drupal.displace
- core/drupal.form
- core/drupal.ajax
- core/drupal.debounce
- core/drupalSettings
- core/drupal.dialog
The Quick Edit module defines jQuery, the jQuery Once plugin, Underscore, and Backbone, and selects other defined libraries as dependencies. Drupal will ensure that these are present whenever the quickedit/quickedit library is attached to a page.
A complete list of the default libraries provided by Drupal core can be found in the core. libraries.yml, which is in core/core.libraries.yml.
No comments:
Post a Comment