Now that we know more about the render arrays, how they are structured and the pipeline they go through, we can talk a bit about asset management from a module development perspective, as although it is usually a theme responsibility, module developers also often have to add and use CSS and JS files to their modules, and it all happens in the render arrays.
Working with CSS and JS files has become standardized in Drupal 8 compared to its preceding version, where you had more than one way to do things. It is doing so via the concept of Libraries, which are now in Drupal 8 core and also work differently than their D7 contrib module counterpart (Libraries API). So, let's see what we have by going through some examples of making use of some CSS of JS files.
There are three steps to this process:
- Creating your CSS/JS file.
- Creating a library that includes...