Gutenberg: Don't add any files to front end's <head>

Created on 25 Jul 2018  路  3Comments  路  Source: WordPress/gutenberg

Is your feature request related to a problem? Please describe.
Just noticed that Gutenberg adds a CSS file (gutenberg/build/core-blocks/style.css) to the front end, breaking my site's optimisation.

Describe the solution you'd like
Please provide an option to not add that file to "head". Thanks.

[Type] Help Request

Most helpful comment

You should be able to use something like this (haven't tested, admittedly, but this should help get you started at least):

add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_style( 'wp-core-blocks' );
} );

All 3 comments

Tested and confirmed that gutenberg/build/core-blocks/style.css is loaded on the front-end with Gutenberg:

screen shot 2018-07-25 at wed jul 25 12 08 23 pm
Seen at http://alittletestblog.com/2018/07/25/summer-night-riverside/ running WordPress 4.9.7 and Gutenberg 3.3.0 using Firefox 61.0.1 on macOS 10.13.6.

I think the solution for this will be to add theme support to replace such styles. I am not sure how to do that, and hopefully someone will chime in with a more technical answer!

You should be able to use something like this (haven't tested, admittedly, but this should help get you started at least):

add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_style( 'wp-core-blocks' );
} );

@chrisvanpatten thanks for the quick response. I added only

wp_dequeue_style( 'wp-core-blocks' );

to my theme styles function and it works.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaronjorbin picture aaronjorbin  路  3Comments

jasmussen picture jasmussen  路  3Comments

pfefferle picture pfefferle  路  3Comments

wpalchemist picture wpalchemist  路  3Comments

mhenrylucero picture mhenrylucero  路  3Comments