Unlock Hidden Gems: Insider Secrets in WordPress 6.8 for Developers
Filter hook for loading block assets on demand
Before WordPress 6.8, the should_load_separate_block_assets
filter hook had two responsibilities:
- To load separate stylesheets for Core blocks instead of always loading the combined
wp-block-library
stylesheet containing all block CSS - To load scripts and styles on demand based on whether they are used on a particular page
In 6.8, a new filter hook named should_load_block_assets_on_demand
exists for the second purpose of determining when to load assets. The original hook will work as before, but it’s recommended to filter it only to override whether stylesheets should be separated.