CSS and JS libraries for your Drupal website
Since these libraries are external, there must be a way to connect to them. But as you know, Drupal will find ways for everything — often with multiple alternatives! Let us introduce the most efficient Drupal’s “librarian” to you.
The Libraries API Drupal module — librarian number one!
- The same libraries can be shared by multiple modules or websites
- Modules that use certain libraries are easily upgraded
- Better compatibility is provided, with no different library versions
- A help widget with instructions lets you install the module easily
…and many more.
The library adding process in Drupal 8
Drupal 8 core has become much stronger in its built-in capacities for handling libraries. However, the realm of adding external libraries that can be used by multiple modules, themes, or websites still belongs to the Libraries API.
In Drupal 8, there is a significant approach shift for adding a library. Drupal 7’s drupal_add_js() and drupal_add_css() functions are gone, but this is a change for the better.
The eighth Drupal version introduces YAML files for handling libraries. This reflects Drupal 8’s best practices of configuration management and add great flexibility and control to the process. One libraries.yml file can define multiple libraries.