amansrivastava/d9-dev

#09 ­- Attaching assets (CSS/JS)

Opened this issue · 0 comments

Objective

At the end of this course, you will be able to

add JS/CSS to a module or a theme to be available on selection / all pages

Exercise

  1. Create a custom module and add a CSS and JS file in appropriate subdirectories in the module.
  2. Create a libraries.yml file and define 2 libraries one for each of the CSS and JS.
  3. Attach the CSS such that it is loaded for all Table elements shown anywhere on the site. Hint
  4. Take any custom block that you have built over the previous exercises. Modify the build() to attach the JS to be loaded whenever the block is displayed. Hint