[wp-trac] [WordPress Trac] #61657: Script "in_footer" => false with "defer" will make all dependencies that are not deferred load in head
WordPress Trac
noreply at wordpress.org
Tue Jun 10 16:18:09 UTC 2025
#61657: Script "in_footer" => false with "defer" will make all dependencies that
are not deferred load in head
-------------------------------+------------------------------
Reporter: kkmuffme | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: performance
-------------------------------+------------------------------
Changes (by westonruter):
* keywords: => reporter-feedback
* focuses: => performance
Comment:
I think I understand. The current logic is such that if `foo` is printed
in the footer, and `bar` is printed in the head, if `bar` depends on `foo`
then `foo` must be moved to the head so as to ensure the correct load
order. But if `bar` is has `defer` then it will ''always'' load after
blocking `foo` anyway, so it can remain in the head.
Are there any cases you're aware of where this is happening? I wonder if
this is an edge case that isn't worth worrying about.
However, if someone were to ''add'' the `defer` loading strategy to `foo`,
then at this point `bar` would have to continue to be moved to the head
since then they would load in the wrong dependency order after the
document has loaded.
> Secondly, I suggest that if a script that has footer false with defer
and an "after" inline script is added to it, it will not just drop the
"defer" but instead convert the footer false to footer true internally
(since this was the original intention of the execution point when it was
registered)
I'm not sure I understand. If a deferred script has an after inline
script, then `defer` has to be removed for safety to ensure that the
inline script is able to access whatever globals that the script may be
defining.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61657#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list