For use of most frameworks (Zurb Foundation, Bootstrap, etc) or libraries (Like Owl carousel, Slick, etc) within a theme, jQuery has to be added as a library.
Is it enough to add jQuery only once as dependencies in a global
library and have it load on every page (imagine that I add this library in Library section of ThemeName.info.yml
) Or would I have to add it as dependencies each time I define a new library again?
For example, is the below structure correct:
global:
css:
# The path to the css file.
assets/css/stylesheets-1.css: {}
assets/css/stylesheets-2.css: {}
js:
assets/js/myglobal.js: {}
dependencies:
- core/jquery
library-A: # Bootstrap Library.
css:
assets/css/stylesheets-3.css: {}
assets/css/stylesheets-4.css: {}
js:
assets/js/myglobal.js: {}
dependencies:
- core/jquery
library-B: # Owl carousel Library.
css:
assets/css/stylesheets-5.css: {}
assets/css/stylesheets-6.css {}
dependencies:
- core/jquery
Is there any problem If I add jQuery once as library in js:
category and again as dependencies:
in one library like library-C
simultaneously? Something like below? Can it cause the conflict?
library-C:
css:
assets/css/stylesheets-c-1.css: {}
assets/css/stylesheets-c-2.css: {}
js:
assets/js/myglobal.js: {}
assets/js/jQuery.js: {}
dependencies:
- core/jquery