Removing Block Editor Stylesheet

Last year when WordPress 5.0 came out, I wrote a simple post showing how to continue using Classic Editor on your WordPress site. Unfortunately though, even after switching to classic editor your site will continue to load the default stylesheet for "Block Editor" aka Gutenberg. I recently noticed the following tag on my site and I had to figure out a way to remove it as I am using the classic editor only and loading this stylesheet all the time does not help my site anyway.

<link rel="stylesheet" id="wp-block-library-css" href="style.min.css" />

This is a sample tag and it will have few other attributes (type, media) which I did not add willingly but you got the idea. Here is the snippet that will get your job done on the fly. However, I honestly think little explanation is necessary.

add_action('wp_enqueue_scripts', function() {
   wp_dequeue_style('wp-block-library');
}, 100);

All you have to do now is simply copy this snippet and paste it on your current theme’s functions.php page.

Explanation

Please note that I have used wp_enqueue_scripts hook over wp_print_styles to dequeue the block stylesheet. Though both the hook will get your job done, it is highly recommended to use the first one. I came across a stackoverflow thread on this topic and it seems like the correct answer also suggested to use the print styles hook. Though technically it is not wrong, one should consider using the enqueue scripts hook, especially if you are planning to add or remove scripts and styles for front-end purpose.

Note: It is not recommended to use this snippet if Block Editor is being used on a WordPress site.

Related

Comments

Comments list