The block editor in WordPress has come a long way, and is — dare I say* — actually quite awesome these days. Especially since the major improvements created with WordPress 6.0, 6.1 and 6.2.
Still, not every WordPress theme needs every bell and whistle available. Some WP sites are just plain ole’ simple blogs, and don’t need a lot of tech. In fact, you’re looking at one right now.
Lean, mean writing machine
I recently upgraded this bad boy to WordPress 6.2, mostly to avoid falling behind on other improvements, unrelated to Gutenberg, Full Site Editing, etc.
Upgrading was painless, of course**, but because WordPress now loads global styles for block assets by default, I had to manually get rid of some weight, to keep the site as lean as always:
Getting rid of all default block styles was not entirely straightforward, as the way to do it has changed multiple times, from version 5.8 through 6.1.
So, without further ado, here’s what I’m using, on this very site, to load just my own, handcrafted theme styles:
Disable block styles in WordPress theme frontend
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
add_action( 'wp_enqueue_scripts', function() {
// https://github.com/WordPress/gutenberg/issues/36834
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
// https://stackoverflow.com/a/74341697/278272
wp_dequeue_style( 'classic-theme-styles' );
// Or, go deep: https://fullsiteediting.com/lessons/how-to-remove-default-block-styles
} );
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
Stick this in your theme’s functions.php
and you should be good to go.