1

I am working on removing the default Gutenberg block library stylesheet and replacing it with custom pared-down styles. I do not want the original stylesheet to load on either the front or back end, as it means I'd need to add unnecessary bulk to the custom styles in order to override styles in the default stylesheet.

I've successfully dequeued the styles from the front end using the standard in a wp_enqueue_scripts action:

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

However, this does not dequeue the styles from the block editor. I have tried dequeuing from an admin_init action as well, and that also does not remove the styles from the block editor.

Is it possible to dequeue this stylesheet from both the front-end and the admin block editor?

1
  • you're using the frontend specific enqueue scripts hook, you should use the admin area specific hook instead, though there's probably a better more official way to do this than dequeuing
    – Tom J Nowell
    May 28, 2021 at 0:12

1 Answer 1

3

Of course, five minutes after I post the question, I find a solution: Using

wp_deregister_style('wp-block-library')

(instead of wp_dequeue_style('wp-block-library')) works for the block editor. It worked in either an admin_init or an admin_enqueue_scripts action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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