Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Library Renderer

1 sites No security coverage Drupal 10–11
View on drupal.org

This module improves page speed by intelligently attaching CSS and JavaScript libraries only when they are needed. It offers flexible options for triggering library attachments based on HTML elements, Twig templates, theme hooks, or theme suggestions. This allows for more efficient loading of assets, leading to better performance and user experience.

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:

  1. html_tags: Attaches a library when HTML output contains a matching DOM element.
  2. templates: Attaches a library when an exact match template.html.twig file is found.
  3. theme_hooks: Attaches a library when a theme hook is invoked.
  4. 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__foo

Note: the module allows combinations of renderers but please pay special attention to formatting YML files as it is prone to error.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Oct 2024
Latest release
3 months ago
Releases (12 mo)
2 ▼ from 3
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.4 Stable 10–11 May 11, 2026
1.0.3 Stable 10–11 Nov 4, 2025
1.0.2 Stable 10–11 Oct 15, 2024
1.0.1 Stable 10–11 Oct 15, 2024
1.0.0 Stable 10–11 Oct 14, 2024