From 0a1354bdfd36fa2d387ca86918666050e892ed31 Mon Sep 17 00:00:00 2001 From: Shyamsundar Gadde <73636812+ShyamGadde@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:08:23 +0530 Subject: [PATCH] Load unminified version of partytown scripts when `SCRIPT_DEBUG` is enabled --- plugins/web-worker-offloading/hooks.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/web-worker-offloading/hooks.php b/plugins/web-worker-offloading/hooks.php index 0b7926f355..6778c61283 100644 --- a/plugins/web-worker-offloading/hooks.php +++ b/plugins/web-worker-offloading/hooks.php @@ -21,7 +21,12 @@ function plwwo_register_default_scripts( WP_Scripts $scripts ): void { // The source code for partytown.js is built from . // See webpack config in the WordPress/performance repo: . - $partytown_js = file_get_contents( __DIR__ . '/build/partytown.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request. + $partytown_js_path = '/build/partytown.js'; + if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { + $partytown_js_path = '/build/debug/partytown.js'; + } + + $partytown_js = file_get_contents( __DIR__ . $partytown_js_path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request. if ( false === $partytown_js ) { return; }