Make WordPress Core

Changeset 62080


Ignore:
Timestamp:
03/20/2026 05:08:33 PM (8 days ago)
Author:
mcsf
Message:

Script Loader: Print import map before classic scripts.

Should any scripts contain calls to import(), the browser won't be able to resolve bare import specifiers unless the import map is already in the DOM. Thus, rather than rely on hook registration order, which is fallible, ensure that the newer callback WP_Script_Modules::print_import_map (since 6.5.0) has a lower priority than _wp_footer_scripts.

Reviewed by jonsurrell.
Props mlaetitia.
Fixes #64907.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-script-modules.php

    r61587 r62080  
    356356        add_action( $position, array( $this, 'print_script_module_preloads' ) );
    357357
    358         add_action( 'admin_print_footer_scripts', array( $this, 'print_import_map' ) );
     358        add_action( 'admin_print_footer_scripts', array( $this, 'print_import_map' ), 9 );
    359359        add_action( 'admin_print_footer_scripts', array( $this, 'print_enqueued_script_modules' ) );
    360360        add_action( 'admin_print_footer_scripts', array( $this, 'print_script_module_preloads' ) );
Note: See TracChangeset for help on using the changeset viewer.