wppaste
WordPress

apply_filters( 'should_load_block_assets_on_demand', bool $load_assets_on_demand )

Since
6.8.0
Filters whether block styles should be loaded on demand.

Description

Returning false loads all block assets, regardless of whether they are rendered in a page or not.
Returning true loads block assets only when they are rendered.

The default value of the filter depends on the result of wp_should_load_separate_core_block_assets(), which controls whether Core block stylesheets should be loaded separately or via a combined 'wp-block-library' stylesheet.

Compatibility

WordPress
since 6.8.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 4 of the 5 tracked releases, added in 6.8.0.

Parameters

$load_assets_on_demandbool
Whether to load block assets only when they are rendered.

Where this hook fires · 1

  • wp-includes/script-loader.php:2764wp_should_load_block_assets_on_demand()

Source code

	 * stylesheet.	 *	 * @since 6.8.0	 *	 * @param bool $load_assets_on_demand Whether to load block assets only when they are rendered.	 */	return apply_filters( 'should_load_block_assets_on_demand', $load_assets_on_demand );} /** * Enqueues registered block scripts and styles, depending on current rendered * context (only enqueuing editor scripts while in context of the editor). *

Changelog

Introduced in 6.8.0. Unchanged from 6.8.8 through 7.1.0.

  1. 6.8.8
  2. 6.9.7
  3. 7.0.4
  4. 7.1.0

Signature, return type and hooks compared across 4 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, 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.