Managing CSS and JavaScript files in Drupal 8 with Libraries

Presenters: davidhernandez

Drupal 8 revolutionizes the theming experience with many significant improvements to make theming easier, and give themers the flexibility and control they've never had before. One of those major improvements is to the library management system, which controls the attaching of CSS and JavaScript files.

In this session we will cover how to create and control libraries from a theme. This will include SMACSS categorization for CSS files, dependencies, how to conditionally attach libraries, manipulating libraries that come from anywhere in a site (core, modules, or base themes,) and targeting individual files for removal or replacement. All this without needing a single line of PHP.

Experience Level
While the topics covered are not difficult, it would be helpful for attendees to have some prior experience theming in Drupal. We will discuss some of the challenges faced managing CSS and JavaScript in previous version of Drupal, and how Drupal 8 aims to solve them. The majority of the code displayed is in YAML format, or from Twig. It is not difficult to understand for a beginner, but some prior knowledge will help.

After this session, attendees should feel comfortable managing assets (CSS and JavaScript files) in Drupal 8 for the majority of use cases. 

Speaker Experience
I have spoken three times at DrupalCon. I have spoken multiple times at DrupalCamp NJ, been on a Drupal Association webcast, and a Modules Unraveled podcast. I also speak frequently at meetups.

This particular session I partly gave at the last DrupalCampNJ in January. It is a subsection of my talk on Drupal 8 theming that I am expanding in greater detail so that I can show more code examples, real world scenarios, and results.

See also this blog post I've written on the topic, which is the basis for a lot of the information contained in the talk -



Experience Level
Schedule Info
Conference Year
Date / Time
Session Track
Design, UX, and Accessibility