[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 21:06:42 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         |  Resolution:
 Keywords:  needs-patch    |     Focuses:  javascript, performance
---------------------------+--------------------------------------
Description changed by westonruter:

Old description:

> 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.
>
> I published an in-depth post ([https://weston.ruter.net/2025/05/26
> /improve-lcp-by-deprioritizing-interactivity-api-script-modules/ Improve
> LCP by Deprioritizing Script Modules from the Interactivity API]) with
> benchmarking results, showing that moving Interactivity API script
> modules from `wp_head` to `wp_footer` alone can
> [https://weston.ruter.net/2025/05/26/improve-lcp-by-deprioritizing-
> interactivity-api-script-
> modules/#:~:text=LCP%20is%20consistent.-,Printing%20Script%20Modules%20in%20the%20Footer,-As%20referred%20to
> improve LCP by ~7%].

New description:

 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.

 I published an in-depth post ([https://weston.ruter.net/2025/05/26
 /improve-lcp-by-deprioritizing-interactivity-api-script-modules/ Improve
 LCP by Deprioritizing Script Modules from the Interactivity API]) with
 benchmarking results, showing that moving Interactivity API script modules
 from `wp_head` to `wp_footer` alone can
 [https://weston.ruter.net/2025/05/26/improve-lcp-by-deprioritizing-
 interactivity-api-script-modules/#printing-script-modules-in-the-footer
 improve LCP by ~7%].

--

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


More information about the wp-trac mailing list