From 3e2121c83de37335bcda944a09c2d1a8f11dab7b Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Fri, 16 Jun 2023 13:26:34 +0000 Subject: [PATCH] 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 --- src/wp-includes/script-loader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 76155ac226..d104598d3f 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -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' ); } }