[wp-trac] [WordPress Trac] #64358: WordPress 6.9, cannot wp_dequeue_style( 'global-styles' );
WordPress Trac
noreply at wordpress.org
Thu Dec 4 18:42:50 UTC 2025
#64358: WordPress 6.9, cannot wp_dequeue_style( 'global-styles' );
---------------------------+------------------------------
Reporter: permanyer | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: 6.9
Severity: normal | Resolution:
Keywords: close | Focuses:
---------------------------+------------------------------
Changes (by westonruter):
* keywords: => close
* component: General => Script Loader
Comment:
@permanyer This is expected. In WordPress 6.8 for classic themes, the
enqueueing of the `global-styles` stylesheet would have been done by
`wp_enqueue_global_styles()` at the `wp_enqueue_scripts` action.
In 6.9, however, block styles now are loaded on demand based on whether or
not a block actually appears in the template. This is how block themes
already behaved, and now classic themes behave the same way. See the
[https://make.wordpress.org/core/2025/11/18/wordpress-6-9-frontend-
performance-field-guide/#load-block-styles-on-demand-in-classic-themes
section in the field guide] about this.
In 6.9, you'll find instead that the logic in `wp_enqueue_global_styles()`
no longer runs at the `wp_enqueue_scripts` action but rather at the
`wp_footer` action (with priority 1). (Again, this is how block themes
behave.) This is why your `mst_enqueues()` function is no longer working
as expected.
So you have a few options. First, you can make sure you re-call
`wp_dequeue_style( 'global-styles' )` after it is enqueued in the footer
by adding this to your plugin:
{{{#!php
<?php
add_action('wp_footer', 'mst_enqueues', 2);
}}}
As a second option, a more robust way to prevent the style from getting
printed is to use the `print_styles_array` filter to exclude it:
{{{#!php
<?php
add_filter(
'print_styles_array',
static function ( $handles ) {
return array_diff( $handles, array( 'global-styles' ) );
}
);
}}}
Lastly, as is explained in the field guide under
"[https://make.wordpress.org/core/2025/11/18/wordpress-6-9-frontend-
performance-field-guide/#load-block-styles-on-demand-in-classic-
themes:~:text=A%20note%20regarding%20themes,to%20be%20false. A note
regarding themes which try to opt out of all block styles]", you can
revert to not loading block styles on demand by adding this
{{{#!php
<?php
add_filter( 'should_load_separate_core_block_assets', '__return_false' );
}}}
This will allow your existing `mst_enqueues()` function to work when it
runs during `wp_enqueue_scripts`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64358#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list