diff --git a/lib/compat/wordpress-6.5/class-wp-script-modules.php b/lib/compat/wordpress-6.5/class-wp-script-modules.php index c51be71438462..c004da668e441 100644 --- a/lib/compat/wordpress-6.5/class-wp-script-modules.php +++ b/lib/compat/wordpress-6.5/class-wp-script-modules.php @@ -235,21 +235,24 @@ public function print_import_map() { * @since 6.5.0 */ public function print_import_map_polyfill() { - $test = 'HTMLScriptElement.supports && HTMLScriptElement.supports("importmap")'; - $src = defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/modules/importmap-polyfill.min.js' ) : includes_url( 'js/dist/vendor/wp-polyfill-importmap.min.js' ); + $import_map = $this->get_import_map(); + if ( ! empty( $import_map['imports'] ) ) { + $test = 'HTMLScriptElement.supports && HTMLScriptElement.supports("importmap")'; + $src = defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/modules/importmap-polyfill.min.js' ) : includes_url( 'js/dist/vendor/wp-polyfill-importmap.min.js' ); - echo ( - // Test presence of feature... - '' - ); + echo ( + // Test presence of feature... + '' + ); + } } /** * Returns the import map array.