[wp-trac] [WordPress Trac] #63486: Script modules should support being printed in the footer the same as classic scripts
WordPress Trac
noreply at wordpress.org
Tue Oct 21 00:44:08 UTC 2025
#63486: Script modules should support being printed in the footer the same as
classic scripts
-------------------------------------+-------------------------------------
Reporter: westonruter | Owner: westonruter
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.9
Component: Script Loader | Version: 6.5
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing | Focuses: javascript,
has-unit-tests needs-dev-note | performance
commit |
-------------------------------------+-------------------------------------
Changes (by westonruter):
* status: reviewing => closed
* resolution: => fixed
Comment:
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/63486#comment:37>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list