Skip to content

Commit

Permalink
Load unminified version of partytown scripts when SCRIPT_DEBUG is e…
Browse files Browse the repository at this point in the history
…nabled
  • Loading branch information
ShyamGadde committed Nov 13, 2024
1 parent 37d8078 commit 0a1354b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/web-worker-offloading/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
function plwwo_register_default_scripts( WP_Scripts $scripts ): void {
// The source code for partytown.js is built from <https://github.com/BuilderIO/partytown/blob/b292a14047a0c12ca05ba97df1833935d42fdb66/src/lib/main/snippet.ts>.
// See webpack config in the WordPress/performance repo: <https://github.com/WordPress/performance/blob/282a068f3eb2575d37aeb9034e894e7140fcddca/webpack.config.js#L84-L130>.
$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;
}
Expand Down

0 comments on commit 0a1354b

Please sign in to comment.