[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes
WordPress Trac
noreply at wordpress.org
Mon Jun 19 11:12:09 UTC 2023
#12009: Add support for HTML 5 "async" and "defer" attributes
-------------------------------------------------+-------------------------
Reporter: Otto42 | Owner: 10upsimon
Type: enhancement | Status: assigned
Priority: high | Milestone: 6.3
Component: Script Loader | Version: 4.6
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests 2nd- | Focuses:
opinion | performance
-------------------------------------------------+-------------------------
Comment (by azaozz):
Replying to [comment:126 westonruter]:
> I’m confused because previously
[https://core.trac.wordpress.org/ticket/12009?replyto=125#comment:86 you
said] that "support for concatenation would not be a priority and probably
won't be necessary.
Yea, sorry, I didn't explain that well at all. The reasons I think support
for concatenation is not needed in the first iteration (this patch) is
because only default core scripts can be concatenated and only in wp-
admin. As there are no default scripts that are (can be) loaded with
`async` or `defer`, adding concatenation support seems an overkill. If
eventually there are enough (new) core scripts that are loaded with
`async` or `defer` by default, it seems concatenation can be added as that
dramatically speeds up page load times on HTTP/1.2.
> Actually, being able to transition applicable core scripts to use a
delayed strategy is specifically what we want to explore once this gets
merged (e.g. `comment-reply`).
Yep, seems the only core script that may be able to be loaded with a
delayed strategy is `comment-reply` (front-end) as it is self-contained
and afaik not used as a dependency. However pretty much all of the rest of
the core scripts are not self-contained and often used as dependencies by
various plugins. In some cases some core scripts are also used in inline
scripts, even scripts that are pasted in post_content. That makes it
virtually impossible to "convert" them to a delayed loading without
bringing regressions and edge cases.
> We’ve specifically developed our implementation in a way that retains
compatibility between core delayed scripts and theme/plugin blocking
scripts. In particular, if a core script adopts a delayed strategy but a
theme/plugin is enqueueing a blocking script that depends on the core-
delayed script, then our implementation forces the core script to revert
to being blocking. So we have implemented a back-compat method to maintain
the loading and execution order, including for before/after inline
scripts.
That would work as long as a script file is enqueued through script-
loader, but will usually fail for stand-alone inline scripts. There are
even scripts that are pasted by admin/editor users in posts, etc. Seen
this type of regressions before, even on big/modern sites...
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12009#comment:127>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list