diff --git a/lib/experimental/modules/class-gutenberg-modules.php b/lib/experimental/modules/class-gutenberg-modules.php index 0a2da03545776..73fbad253b233 100644 --- a/lib/experimental/modules/class-gutenberg-modules.php +++ b/lib/experimental/modules/class-gutenberg-modules.php @@ -266,11 +266,13 @@ function gutenberg_dequeue_module( $module_identifier ) { // Prints the import map in the head tag in block themes. Otherwise in the footer. add_action( $modules_position, array( 'Gutenberg_Modules', 'print_import_map' ) ); -// Prints the enqueued modules in the head tag in block themes. Otherwise in the footer. +// Prints the enqueued modules in the head tag in block themes. add_action( $modules_position, array( 'Gutenberg_Modules', 'print_enqueued_modules' ) ); -// Prints the preloaded modules in the head tag in block themes. Otherwise in the footer. -add_action( $modules_position, array( 'Gutenberg_Modules', 'print_module_preloads' ) ); +// Prints the preloaded modules in the head tag in block themes. +if ( 'wp_head' === $modules_position ) { + add_action( 'wp_head', array( 'Gutenberg_Modules', 'print_module_preloads' ) ); +} // Prints the script that loads the import map polyfill in the footer. add_action( 'wp_footer', array( 'Gutenberg_Modules', 'print_import_map_polyfill' ), 11 );