How to Remove Block Library CSS from WordPress 6
WordPress 5 & 6 has been moved to the new WordPress editor Gutenberg. That is the default editor for the latest WordPress installations, uses special CSS libraries to manage blocks on your site’s frontend.
This means that your website will be included in default CSS from Gutenberg. With millions of fans of Classic Editor Plugin, this becomes superfluous and contributes to slow site loading time, so if you’re not using Gutenberg editor you’ll want to remove Gutenberg CSS from the front-end website.
wp-includes/css/dist/block-library/style.min.css
Block library style.min.css CSS loading on all WordPress pages
I know you are a fan of WordPress optimization. You can remove Gutenberg CSS by using the wp_dequeue_style function to dequeue the “/wp-includes/css/dist/block-library/style.min.css” file. Below is the snippet to remove this extra stylesheet from your theme.
function dm_remove_wp_block_library_css(){ wp_dequeue_style( 'wp-block-library' ); } add_action( 'wp_enqueue_scripts', 'dm_remove_wp_block_library_css' );
Open the function.php file of your theme and add this snippet, everything is resolved.
If you want to remove “block-library/style.min.css” file when the site is running.
Please follow the following 4 steps to make your WordPress fly!
- Log in to your WordPress Admin.
- On left menu choose the Appearance -> Theme Editor
- Find the Theme Function fie (function.php) in Theme Files listed.
- Add the above snippet to the bottom of the file and click to button Update File.
Now Your WordPress site has been removed “Block library CSS” on the Front-end!
Is there a way to target anonymous users only so the css doesn’t load? That way registered users could still use the G blocks.
Hi Matt,
You can use function: !is_user_logged_in()
Hi, g;ad to find this. So basically, if I installed the Classic Editor (never using blocks) I can safely remove this?
Hi Andre,
Yes, you can safely delete it.
Nice .. I was hesitating to remove that file and was wondering if it is going to affect the website.. Thanks for the useful information.
Hi Shiva,
It is what’s attached by Gutenberg editor. If you edit content based on Gutenberg, you don’t remove it.
Thank you!