From e0a3b78cf18a4933d0360cb858ca5db556a30dd9 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Thu, 30 Mar 2023 11:06:31 +0000 Subject: [PATCH] Script Loader: Return early in _wp_theme_json_webfonts_handler if theme.json not present. Check to see if the theme.json file exists before processing the rest of the code in `_wp_theme_json_webfonts_handler`. This improves performance by not trying to parse the theme.json, early in the bootstrap process. Props spacedmonkey, hellofromTonya, flixos90. Fixes #57814. git-svn-id: https://develop.svn.wordpress.org/trunk@55612 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index cd84a19f6c..e0e01299a0 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -3225,6 +3225,10 @@ function _wp_theme_json_webfonts_handler() { return; } + if ( ! wp_theme_has_theme_json() ) { + return; + } + // Webfonts to be processed. $registered_webfonts = array();