In order to avoid a Flash of Unstyled Content (FOUC), browsers will halt rendering when they encounter a CSS include until the file is downloaded and its rules are parsed. By default, Drupal includes all page CSS in the document header, which increases the transfer and parsing time before the browser is able to first render any of the page.
By including non-essential CSS when it's first needed on the page instead of in the header, the browser can more quickly render initially visible content, providing a better experience for users.
Usage
In a template, replace {{ attach_library('extension/library') }} with {{ attach_library_inbody('extension/library') }}
Any CSS and JS assets will be rendered in that template, while any dependencies of that library will be rendered in the header or footer of the page as usual.
Resources
Project information
- Project categories: Performance
2 sites report using this module
- Created by gapple on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 8.x-1.x-dev updated 28 May 2024 at 06:41 UTC
