Filter hook 'should_load_separate_core_block_assets'

in WP Core File wp-includes/script-loader.php at line 2630

View Source

should_load_separate_core_block_assets

Filter Hook
Description
Filters whether block styles should be loaded separately. 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.

Hook Information

File Location wp-includes/script-loader.php View on GitHub
Hook Type Filter
Line Number 2630

Hook Parameters

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

Usage Examples

Basic Usage
<?php
// Hook into should_load_separate_core_block_assets
add_filter('should_load_separate_core_block_assets', 'my_custom_filter', 10, 1);

function my_custom_filter($load_separate_assets) {
    // Your custom filtering logic here
    return $load_separate_assets;
}

Source Code Context

wp-includes/script-loader.php:2630 - How this hook is used in WordPress core
<?php
2625  	 * @since 5.8.0
2626  	 *
2627  	 * @param bool $load_separate_assets Whether separate assets will be loaded.
2628  	 *                                   Default false (all block assets are loaded, even when not used).
2629  	 */
2630  	return apply_filters( 'should_load_separate_core_block_assets', false );
2631  }
2632  
2633  /**
2634   * Checks whether block styles should be loaded only on-render.
2635   *

PHP Documentation

<?php
/**
	 * Filters whether block styles should be loaded separately.
	 *
	 * 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.
	 *
	 * @since 5.8.0
	 *
	 * @param bool $load_separate_assets Whether separate assets will be loaded.
	 *                                   Default false (all block assets are loaded, even when not used).
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/script-loader.php
Related Hooks

Related hooks will be displayed here in future updates.