Checks whether separate styles should be loaded for core blocks on-render.
Description
When this function returns true, other functions ensure that core blocks only load their assets on-render, and each block loads its own, individual assets. Third-party blocks only load their assets when rendered. When this function returns false, all core block assets are loaded regardless of whether they are rendered in a page or not, because they are all part of the block-library/style.css file. Assets for third-party blocks are always enqueued regardless of whether they are rendered or not. This only affects front end and not the block editor screens.
Return
bool
Whether separate assets will be loaded.
Hooks fired · 1
One hook fires while wp_should_load_separate_core_block_assets() runs, in this order:
Filters whether block styles should be loaded separately.
Uses · 4
is_admin()Determines whether the current request is for an administrative interface page.
is_feed()Determines whether the query is for a feed.
wp_is_rest_endpoint()Checks whether a REST API endpoint request is currently being handled.
apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 10
enqueue_block_styles_assets()Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
register_block_style_handle()Finds a style handle for the block metadata field. It detects when a path to file was provided and registers the style under automatically generated handle name. It returns unprocessed style handle otherwise.
wp_enqueue_registered_block_scripts_and_styles()Enqueues registered block scripts and styles, depending on current rendered context (only enqueuing editor scripts while in context of the editor).
2589functionwp_should_load_separate_core_block_assets(){2590if(is_admin()||is_feed()||wp_is_rest_endpoint()){2591returnfalse;2592}25932594/**2595 * Filters whether block styles should be loaded separately.2596 *2597 * Returning false loads all core block assets, regardless of whether they are rendered2598 * in a page or not. Returning true loads core block assets only when they are rendered.2599 *2600 * @since 5.8.02601 *2602 * @param bool $load_separate_assets Whether separate assets will be loaded.2603 * Default false (all block assets are loaded, even when not used).2604 */2605returnapply_filters('should_load_separate_core_block_assets',false);2606}
History
Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/script-loader.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.