Skip to content

Commit

Permalink
chore(blockEditor.php): optimize dequeueing of Gutenberg block styles
Browse files Browse the repository at this point in the history
  • Loading branch information
timohubois committed Jul 17, 2024
1 parent 084dabd commit 7fd4944
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions inc/blockEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
* Remove Gutenberg block related styles on front-end, when a post has no blocks.
*/
add_action('wp_enqueue_scripts', function (): void {
if (!has_blocks()) {
wp_dequeue_style('core-block-supports');
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('global-styles');
if (has_blocks()) {
return;
}

wp_dequeue_style('core-block-supports');
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('wp-global-styles');
wp_dequeue_style('block-style-variation-styles');
});

0 comments on commit 7fd4944

Please sign in to comment.