If, we have to load CSS and JS in header or footer in Drupal 8, so we will call our CSS or JS in '*.libraries.yml' file, there we will use scope attribute for this purpose.
we just have to pass the option value either header or footer.
like: scope:footer or scope:header
Example:
If our yml file is mytheme.libraries.yml and we are attached assets there..
slick_slider:
css:
theme:
slick.min.css: { type: external, scope:footer }
js:
slick.min.js: { type: external, minified: true, scope: header }
dependencies:
- core/jquery
Note: If have any suggestions or issue regarding 'How to load CSS or JS in footer?' then you can ask by comments.
No comments:
Post a Comment