[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes
WordPress Trac
noreply at wordpress.org
Mon Mar 5 19:36:59 UTC 2018
#12009: Add support for HTML 5 "async" and "defer" attributes
---------------------------+-----------------------------
Reporter: Otto42 | Owner: azaozz
Type: enhancement | Status: reopened
Priority: normal | Milestone: Future Release
Component: Script Loader | Version: 4.6
Severity: normal | Resolution:
Keywords: | Focuses:
---------------------------+-----------------------------
Comment (by azaozz):
Replying to [comment:40 mor10]:
> Concatenating JavaScript is an old patch to get around single-stream
transfer under HTTP/1.1. With HTTP/2 multiplexing...
All of this sounds pretty good, in theory. I wish we could do that right
now. The problem is that less than 25% of the websites currently support
HTTP/2: https://w3techs.com/technologies/details/ce-http2/all/all.
> > In addition `async` cannot be used if the script has dependencies or
is used as dependency for another script.
> Not entirely accurate.
The `async` attribute cannot be used in script-loader because the script
doesn't follow execution order. If you are adding a stand-alone script
that has no dependencies and other scripts don't depend on it, there is no
point adding it to script loader at all.
Right now plugins and themes can load all scripts in the head and add
`defer` if they really want by using the `'script_loader_tag'` filter.
This will make 75% of sites slower. Whether we should make this easier is
another question. I'd rather we don't.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12009#comment:43>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list