How to Remove Block Library CSS from WordPress 6

envato

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!

  1. Log in to your WordPress Admin.
  2. On left menu choose the  Appearance -> Theme Editor
  3. Find the Theme Function fie (function.php) in Theme Files listed.
  4. 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!

Comments (6)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>