Attach In-Body
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
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
Releases
| Version | Type | Core | Release date | |
|---|---|---|---|---|
| 8.x-1.2 | Stable | May 22, 2024 |