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.


Top ↑

Parameters

$load_separate_assets bool
Whether separate assets will be loaded.
Default false (all block assets are loaded, even when not used).

Top ↑

Source

File: wp-includes/script-loader.php. View all references

return apply_filters( 'should_load_separate_core_block_assets', false );


Top ↑

Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Will Skora

    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.

You must log in before being able to contribute a note or feedback.