Themes: Inline render blocking CSS `classic-themes.css'

Since [54358], a new CSS file classic-themes.css is enqueued on all pages on the front end of themes without `theme.json`. This is a blocking http request, the impact on performance will be affected by network conditions. Inlining this style, stops this blocking request. By adding style data of path to the registered style, the function `wp_maybe_inline_styles` will automatically inline the style for us. 

Props spacedmonkey, adamsilverstein.
Fixes #58480.

git-svn-id: https://develop.svn.wordpress.org/trunk@55930 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonny Harris 2023-06-16 13:26:34 +00:00
parent 1d1a2e3dec
commit 3e2121c83d

View File

@ -3718,6 +3718,7 @@ function wp_enqueue_classic_theme_styles() {
if ( ! wp_theme_has_theme_json() ) {
$suffix = wp_scripts_get_suffix();
wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css" );
wp_style_add_data( 'classic-theme-styles', 'path', ABSPATH . WPINC . "/css/classic-themes$suffix.css" );
wp_enqueue_style( 'classic-theme-styles' );
}
}