Using the new asset management system

New to Drupal 8 is the asset management system. The asset management system allows modules and themes to register libraries. Libraries define CSS stylesheets and JavaScript files that need to be loaded with the page. Drupal 8 takes this approach for the frontend performance. Rather than loading all CSS or JavaScript assets, only those required for the current page in the specified libraries will be loaded.

In this recipe, we will define a libraries.yml file that will define a CSS stylesheet and JavaScript file provided by a custom theme.

Getting ready

This recipe assumes that you have a custom theme created, such as the one you created in the first recipe. When you see mytheme, use the machine name of the theme ...

Get Drupal 8: Enterprise Web Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.