Support » Fixing WordPress » Remove global-styles-inline-css

  • Resolved RS

    (@rsdotscot)


    Hi folks,

    I’ve just updated a site which doesn’t use Gutenberg to 5.9 and a huge block of styling has appeared at the top of every page (id=”global-styles-inline-css”).

    How do we go about removing this?

    Cheers,
    RS

    • This topic was modified 5 months, 1 week ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi Rs,

    just dequeue the ‘global-styles’ style using wp_dequeue_style

    Also…

    I’ve just updated a site which doesn’t use Gutenberg to 5.9

    Unless you’ve taken steps to actually disable the block editor (aka Gutenberg) completely, then you’re using Gutenberg by default. You don’t need to use the Gutenberg plugin to use Gutenberg, and merely using another page builder plugin does not necessarily disable Gutenberg.

    Thread Starter RS

    (@rsdotscot)

    @thedock much appreciated. I’ll give it a bash.

    @gappiah I’ve only been using WP for 18 years across countless installations at this point, but thanks for talking to me like I’m a complete novice. FYI I hate page builders and this site uses the classic editor.

    Thread Starter RS

    (@rsdotscot)

    @thedock I’ve tried adding an action to wp_enqueue_scripts, wp_footer, and even wp_print_styles, but no luck so far. Any ideas?

    add_action( 'wp_enqueue_scripts', function() {
    	wp_dequeue_style( 'global-styles-inline-css' );
    	wp_deregister_style( 'global-styles-inline-css' );
    }, 100000 );

    you don’t need to include the ‘inline-css’ suffix, that’s added by WP since the style is inline enqueued with the function wp_add_inline_style().

    wp_dequeue_style( ‘global-styles’ );

    should do it.

    • This reply was modified 5 months, 1 week ago by thedock.
    Thread Starter RS

    (@rsdotscot)

    @thedock that did the trick, thanks 🙂

    Thread Starter RS

    (@rsdotscot)

    [Marking as resolved]

    Gik000

    (@gik000)

    This is not solving the problem in my case.

    Global inline styles are always there.

    I did that in my child theme:

    /**
     * Remove global script
     */
    add_action( 'wp_enqueue_scripts', function() {
    	wp_dequeue_style( 'global-styles' );
    	wp_deregister_style( 'global-styles' );
    }, PHP_INT_MAX );

    I also have tried with the inline suffix, but it didn’t work.

    Gik000

    (@gik000)

    I got a solution

        remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
        remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );

    see
    https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/

    Unfortunately, none of these are working for me. Very annoying. @gik000 is it still working for you with the latest WP update?

    Try this

    add_action( 'init',function(){
        remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
        remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
        remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
      } );
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.