This project is not covered by Drupal’s security advisory policy.
The library renderer provides component and DOM level rendering of libraries.
Using component or DOM level rendering will increase page speed by only attaching libraries as and when required.
Features
The module provides four options for attaching a library:
- html_tags: Attaches a library when HTML output contains a matching DOM element.
- templates: Attaches a library when an exact match template.html.twig file is found.
- theme_hooks: Attaches a library when a theme hook is invoked.
- theme_suggestions: Provides fuzzy template matching against template suggestions.
These options provide fine-grained control over how and when libraries are rendered. When combined with component-level CSS and JS files, page load speed is enhanced and you will achieve better results in tools like Page Speed Insights whilst enhancing user experience and reducing bandwidth.
Post-Installation
Once the module is installed you can upgrade your libraries.yml file by using the following example as a template:
example_library:
css:
component:
theme/dist/example.css: { minified: true }
js:
theme/dist/example.js: { minified: true }
dependencies:
- core/jquery
library_renderer:
html_tags:
pre: { }
code: { attributes: { class: 'language-php' } }
templates:
- field.html.twig
- foo.html.twig
theme_hooks:
- input__submit
- block
theme_suggestions:
- field__paragraph__example
- field__fooNote: the module allows combinations of renderers but please pay special attention to formatting YML files as it is prone to error.
Project information
- Project categories: Developer tools, Performance, Search engine optimization (SEO)
- Ecosystem: Drupal core
2 sites report using this module
- Created by jnorton on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
