apply_filters( 'should_load_separate_core_block_assets', bool $load_separate_assets )
Filters whether block styles should be loaded separately.
Description
Returning false loads all core block assets, regardless of whether they are rendered in a page or not. Returning true loads core block assets only when they are rendered.
Parameters
- $load_separate_assets
-
(bool) Whether separate assets will be loaded. Default false (all block assets are loaded, even when not used).
Source
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
This hook is poorly named: when returning `true` with this hook; many 3rd-party blocks’ assets (JS and CSS) will only load when those blocks are being used on a page; slightly speeding up your website.
To use:
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
it only needs to be added once for each instance of WordPress you are working with; you do not need to add for each block or plugin that you wish to conditionally load.Top ↑
Feedback
This hook affects only loading of core blocks, not third party blocks, hence the name *_core_block_assets — By Lovro Hrust —