Closed ronilaukkarinen closed 2 years ago
This hasn't bothered us in the newest WordPress version so closing this for now. Let's open issue again if the problem reoccurs.
Just noticed Autoptimize has "Remove WordPress block CSS" which seems to work well.
Hook-wise it works like this:
public function disable_global_styles()
{
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' );
if ( true === apply_filters( 'autoptimize_filter_extra_global_styles_and_block_css', true ) ) {
add_action(
'wp_enqueue_scripts',
function() {
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
}
);
}
}
Opening for consideration whether we add this functionality to air-helper or to this theme and build those blocks ourselves or trust Gutenberg with their CSS. The gallery block etc. have been quite good lately so it might be best to live with the extra block theme CSS and combine styles with Autoptimize instead.
We have re-valuated this and discussed that we won't be supporting our own core blocks and will have Gutenberg as dependency instead. This way we make sure that blocks retain good quality. It's extra HTTP request but the CSS file is not that large so it doesn't bother us that much at this time.
It seems our hook for removing the default styles and resets no longer works. Opening an issue to here as well to keep the situation up to date. Referring to my issue comment in Gutenberg repo:
Let's see what we can do about this.