Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

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.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Performance
  • Tested with WordPress 7.1
PHP
<?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.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.