[wp-trac] [WordPress Trac] #61734: Add the ability to handle "fetchpriority" to ES Modules and Import Maps

WordPress Trac noreply at wordpress.org
Tue Oct 21 00:44:09 UTC 2025


#61734: Add the ability to handle "fetchpriority" to ES Modules and Import Maps
-------------------------------------+-------------------------------------
 Reporter:  dennysdionigi            |       Owner:  westonruter
     Type:  enhancement              |      Status:  closed
 Priority:  normal                   |   Milestone:  6.9
Component:  Script Loader            |     Version:  6.5
 Severity:  minor                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-      |     Focuses:  javascript,
  tests needs-dev-note               |  performance
-------------------------------------+-------------------------------------

Comment (by westonruter):

 In [changeset:"60999" 60999]:
 {{{
 #!CommitTicketReference repository="" revision="60999"
 Script Loader: Add support for printing script modules at `wp_footer`.

 This brings API parity with `WP_Scripts` by implementing opt-in support
 for printing in the footer via an `in_footer` argument. This argument can
 be supplied via the `$args` array passed to `wp_enqueue_script_module()`
 or `wp_register_script_module()`, alongside the existing `fetchpriority`
 key introduced in #61734. It can also be set for previously-registered
 script modules via `WP_Script_Modules::set_in_footer()`. This is not
 applicable to classic themes since modules are enqueued while blocks are
 rendered after `wp_head` has completed, so all script modules are printed
 in the footer anyway; the `importmap` script must be printed after all
 script modules have been enqueued.

 Script modules used for interactive blocks (with the Interactivity API)
 are automatically printed in the footer. Such script modules should be
 deprioritized because they are not in the critical rendering path due to
 interactive blocks using server-side rendering. Script modules remain
 printed at `wp_head` by default, although this default should be revisited
 since they have deferred execution (and they are printed in the footer for
 classic themes already, as previously noted). Moving a script module to
 the footer ensures that its loading does not contend with the loading of
 critical resources, such as the LCP element's image resource, and LCP is
 improved as a result.

 This also improves specificity of some PHP types, it ensures that script
 modules can't be registered with an empty ID, and it prevents printing
 script modules with empty `src` URLs.

 Developed in https://github.com/WordPress/wordpress-develop/pull/9867

 Follow-up to [60704].

 Props b1ink0, westonruter, jonsurrell, peterwilsoncc, vipulpatil,
 mindctrl.
 See #61734.
 Fixes #63486.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61734#comment:50>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list