[wp-trac] [WordPress Trac] #63793: Parser-blocking scripts should render last in all cases to speed up page load
WordPress Trac
noreply at wordpress.org
Thu Aug 7 00:58:31 UTC 2025
#63793: Parser-blocking scripts should render last in all cases to speed up page
load
---------------------------+-----------------------------
Reporter: kkmuffme | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version:
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
Since <script> tags are render and parser blocking, WP should print all
scripts that have neither defer/async (as effective strategy! the intended
/data-wp-strategy is irrelevant) last*, after all other scripts.
*taking into account dependencies of course. This means that all scripts
that have dependencies or inline/localized, should also be moved as late
as possible.
{{{
<script>var a = 'localized';</script>
<script>console.log( 'aInlineScript' );</script>
<script src="a.js" defer>
<script src="b.js">
<script src="c.js" async>
<script src="d.js" defer>
}}}
Printing them in the following order, will significantly speed up reaching
DOMContentLoaded, without having any impact on functionality:
{{{
<script src="d.js" defer>
<script src="c.js" async>
<script>var a = 'localized';</script>
<script>console.log( 'aInlineScript' );</script>
<script src="a.js" defer>
<script src="b.js">
}}}
Additionally, afaik all "async" should be printed after all "defer", since
executing the async JS will potentially delay further parsing (thus
delaying the download of any unparsed scripts)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63793>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list