[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
Mon May 26 18:15:57 UTC 2025
#63486: Script modules should support being printed in the footer the same as
classic scripts
-------------------------------------+----------------------------
Reporter: westonruter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Script Loader | Version: 6.5
Severity: normal | Keywords: needs-patch
Focuses: javascript, performance |
-------------------------------------+----------------------------
Script modules are always printed at `wp_head` in block themes. This makes
sense in that script modules have the `defer` behavior by default, so they
do not block rendering. By placing them in the `head`, they can be
discovered early which is helpful when any script modules are in the
critical rendering path. However, all script modules in WordPress core are
for the Interactivity API which has [https://developer.wordpress.org
/block-editor/reference-guides/interactivity-api/iapi-
about/#:~:text=It%20must%20support%20server%2Dside%20rendering.%20Server%2Drendered%20HTML%20and%20client%2Dhydrated%20HTML%20must%20be%20exactly%20the%20same.%20This%20is%20important%20for%20SEO%20and%20the%20user%20experience.
server-side rendering] as a top goal/requirement:
> It must support server-side rendering. Server-rendered HTML and client-
hydrated HTML must be exactly the same. This is important for SEO and the
user experience.
Therefore, all script modules for the Interactivity API should be
deprioritized to not compete with the loading of any resources needed in
the critical rendering path, especially any image resource for the LCP
element. One way to reduce the priority of the script modules is to add
`fetchpriority=low` to the `script` tags (#61734), and the other way is to
print the script module in the footer. Implementing both deprioritization
techniques yields the highest improvement to LCP in my testing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63486>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list