skip to Main Content

I just want some clarification and advice regarding this tag in WordPress.

This tag is showing in my WordPress head even I’m not using Gutenberg.

link rel="stylesheet" id="wp-block-library-css"

Is this necessary or required?
Do I need to remove this to improve page speed?
Is there any effect if I remove this tag?

Please enlighten me.

Thank you

2

Answers


  1. I use to remove this stylesheet on websites which are not using Gutenberg.

    I don’t think there is other effect than removing this stylesheet, you can do it safely.

    To go a bit further, you can remove it only for some post types like

    function remove_wp_block_library_css() {
      if( !is_singular('post') ) {
        wp_dequeue_style( 'wp-block-library' );
      }
    }
    add_action( 'wp_enqueue_scripts', 'remove_wp_block_library_css' );
    
    Login or Signup to reply.
  2. If you are not using Gutenberg at all, you can unload styles further more like this :

    // Unload Gutenberg-related stylesheets.
    add_action( 'wp_enqueue_scripts', 'remove_block_css', 100 );
    function remove_block_css() {
        wp_dequeue_style( 'wp-block-library' ); // WordPress core
        wp_dequeue_style( 'wp-block-library-theme' ); // WordPress core
        wp_dequeue_style( 'wc-block-style' ); // WooCommerce
        wp_dequeue_style( 'storefront-gutenberg-blocks' ); // Storefront theme
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search