Remove Gutenberg stylesheet from WordPress

Remove Gutenberg stylesheet from WordPress to make the website lighter and load faster.
Thus, WordPress 5.0 has officially been launched for nearly 3 weeks. And since then, the number of people who install Classic Editor plugin to switch to using the classic editor of WordPress has also increased dramatically (more than 1 million websites are activating this plugin), enough to see How Gutenberg lost his heart. Not only causing discomfort and inconvenience to use, Gutenberg also "silently" uploads his stylesheet to the front-end of the website, making the WordPress source code more cumbersome.

What is the Gutenberg stylesheet?

There are 2 CSS files, including wp-block-library-cssand wp-block-library-theme-css, automatically downloaded on all websites using WordPress version 5.0 and above. They are still loaded even if you don't use the Gutenberg editor or have installed the plugin to replace it with the Classic Editor.
gutenberg-stylesheet-wp-block-library
Although these 2 files are not large, they will also affect the speed of website loading. Therefore, if you don't use Gutenberg, it's best to disable them.

How to remove Gutenberg stylesheet?

Very simple! All you need to do is insert the following code at the end functions.phpof the theme file (or child theme) you are using and save.
// * Disable Gutenberg stylesheet in front
function wps_deregister_styles () {
wp_dequeue_style ('wp-block-library');
wp_dequeue_style ('wp-block-library-theme');
}
add_action ('wp_print_styles', 'wps_deregister_styles', 100);
view rawfunctions.php hosted with ❤ by GitHub
Clear the website cache, browse the web browser and check the results. If nothing changes, the two lines of Gutenberg stylesheet will disappear when you view the source website.
go-bo-gutenberg-stylesheet-wp-block-library
Isn't it great? Good luck!
If you like this post, please subscribe to my blog to regularly update the best, latest posts via email. Thanks very much. :)

Disqus Comments