Load styles only for blocks on the page
Classic themes load the CSS for every block on every page. This loads only the styles of blocks actually used on the page.
<?php
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
Good to know
Block themes do this already. Check your pages after switching it on: a few older themes expect the full stylesheet.
In these packs
- More speed: More ways to load less: block styles, speculative loading, fewer scripts.