From 7940946d0bdf5e51c760a8555eb806f1d5f42e88 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 19 Mar 2026 22:15:56 -0400 Subject: [PATCH 1/3] Remove unminified `.min` files. This removes the `script-loader-packages.min.php` and `script-modules-packages.min.php` files. They were not being minified and an unminified vesion of the file is more human readable. The unminified file is roughly 10KB larger, which seems like a reasonable tradeoff. --- src/wp-includes/script-loader.php | 4 +- src/wp-includes/script-modules.php | 12 +++-- tools/gutenberg/copy.js | 85 ++++++++---------------------- 3 files changed, 31 insertions(+), 70 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index d006c4fe32945..b80853f66429d 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -281,11 +281,11 @@ function wp_default_packages_scripts( $scripts ) { * 'annotations.js' => array('dependencies' => array(...), 'version' => '...'), * 'api-fetch.js' => array(... */ - $assets_file = ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php"; + $assets_file = ABSPATH . WPINC . '/assets/script-loader-packages.php'; $assets = file_exists( $assets_file ) ? include $assets_file : array(); foreach ( $assets as $file_name => $package_data ) { - $basename = str_replace( $suffix . '.js', '', basename( $file_name ) ); + $basename = str_replace( '.js', '', basename( $file_name ) ); $handle = 'wp-' . $basename; $path = "/wp-includes/js/dist/{$basename}{$suffix}.js"; diff --git a/src/wp-includes/script-modules.php b/src/wp-includes/script-modules.php index 411325be3618e..c9afb2614b232 100644 --- a/src/wp-includes/script-modules.php +++ b/src/wp-includes/script-modules.php @@ -149,11 +149,11 @@ function wp_default_script_modules() { /* * Expects multidimensional array like: * - * 'interactivity/index.min.js' => array('dependencies' => array(…), 'version' => '…'), - * 'interactivity-router/index.min.js' => array('dependencies' => array(…), 'version' => '…'), - * 'block-library/navigation/view.min.js' => … + * 'interactivity/index.js' => array('dependencies' => array(…), 'version' => '…'), + * 'interactivity-router/index.js' => array('dependencies' => array(…), 'version' => '…'), + * 'block-library/navigation/view.js' => … */ - $assets_file = ABSPATH . WPINC . "/assets/script-modules-packages{$suffix}.php"; + $assets_file = ABSPATH . WPINC . '/assets/script-modules-packages.php'; $assets = file_exists( $assets_file ) ? include $assets_file : array(); foreach ( $assets as $file_name => $script_module_data ) { @@ -192,8 +192,10 @@ function wp_default_script_modules() { // VIPS files are always minified — the non-minified versions are not // shipped because they are ~10MB of inlined WASM with no debugging value. - if ( str_starts_with( $file_name, 'vips/' ) && ! str_contains( $file_name, '.min.' ) ) { + if ( str_starts_with( $file_name, 'vips/' ) ) { $file_name = str_replace( '.js', '.min.js', $file_name ); + } elseif ( '' !== $suffix ) { + $file_name = str_replace( '.js', $suffix . '.js', $file_name ); } $path = includes_url( "js/dist/script-modules/{$file_name}" ); diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index 3a7fc67ad7485..3506067552d92 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -351,14 +351,13 @@ function copyBlockAssets( config ) { } /** - * Generate script-modules-packages.min.php from individual asset files. + * Generate script-modules-packages.php from individual asset files. * Reads all view.min.asset.php files from modules/block-library and combines them * into a single PHP file. */ function generateScriptModulesPackages() { const modulesDir = path.join( gutenbergBuildDir, 'modules' ); - const assetsMin = {}; - const assetsRegular = {}; + const assets = {}; /** * Recursively process directory to find .asset.php files. @@ -384,16 +383,13 @@ function generateScriptModulesPackages() { const normalizedPath = relativePath .split( path.sep ) .join( '/' ); - const jsPathMin = normalizedPath.replace( - /\.asset\.php$/, - '.js' - ); - const jsPathRegular = jsPathMin.replace( /\.min\.js$/, '.js' ); + const jsPath = normalizedPath + .replace( /\.asset\.php$/, '.js' ) + .replace( /\.min\.js$/, '.js' ); try { const assetData = readReturnedValueFromPHPFile( fullPath ); - assetsMin[ jsPathMin ] = assetData; - assetsRegular[ jsPathRegular ] = assetData; + assets[ jsPath ] = assetData; } catch ( error ) { console.error( ` ⚠️ Error reading ${ relativePath }:`, @@ -406,52 +402,35 @@ function generateScriptModulesPackages() { processDirectory( modulesDir, modulesDir ); - // Generate both minified and non-minified PHP files using json2php. - const phpContentMin = - ' Date: Thu, 19 Mar 2026 22:33:13 -0400 Subject: [PATCH 2/3] Improve inline documenation. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tools/gutenberg/copy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index 3506067552d92..9d3481a8df5c1 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -352,8 +352,8 @@ function copyBlockAssets( config ) { /** * Generate script-modules-packages.php from individual asset files. - * Reads all view.min.asset.php files from modules/block-library and combines them - * into a single PHP file. + * Recursively scans the Gutenberg modules/ directory for *.min.asset.php files + * and combines their contents into a single PHP file. */ function generateScriptModulesPackages() { const modulesDir = path.join( gutenbergBuildDir, 'modules' ); From cb4fee493364cf52967850514df336fc26774def Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:57:36 -0400 Subject: [PATCH 3/3] Indent PHP with tabs, not spaces. --- tools/gutenberg/copy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index 9d3481a8df5c1..b84ecc55a3449 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -406,7 +406,7 @@ function generateScriptModulesPackages() { '