0

Is it possible to un-enqueue stylesheets for the built-in Gutenberg block types?

e.g. I would like to add custom styles for the Gutenberg Columns block, so I'd like to un-enqueue the stylesheets just for this block type, but keep the default styles for the others.

1

In Gutenberg and plugins for Gutenberg are all styles involved via wp_enqueue_style. I would to see all developers use wp_register_style before, makes easier to deregister. However you should un-enqueue the style via the core function wp_dequeue_style.

So this should work, in dependency of the hook and handle of the style and his handle, here for example gutenberg-handle-foo.

add_action('wp_print_styles', function() {
    wp_dequeue_style('gutenberg-handle-foo');
}, 99);

A screenshot

about handle examaples in the WP Admin Edit Post screen, version 5.2 of WP.

enter image description here

  • Any idea where I might find the handle for the core blocks? – benedict_w Jan 17 at 15:42
  • Yes, the plugin Query Monitor has a feature to list all blocks, there are installed, see twitter.com/johnbillion/status/1071563623280070656 – bueltge Jan 18 at 10:07
  • Does this actually work? Gutenberg enqueues a single CSS file containing styles for all its core blocks, so I don't think it is possible to dequeue/enqueue styles for a single block. – Jonathan Nicol Apr 16 at 6:23
  • I mean yes, but not tested. However lot of handles are still existent, see the screenshot above. – bueltge Apr 16 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.