[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes
WordPress Trac
noreply at wordpress.org
Tue Mar 6 13:09:37 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:47 westonruter]:
> Retiring `load-scripts.php` I think can also/rather be accomplished via
service workers: #36995.
Right. This can be done in couple of different ways. The point is that it
makes sense as part of refactoring how we load scripts in general.
> It would make sense to me that if you register a script with an `async`
flag ''and'' a non-empty `deps` that this should result in a
`_doing_it_wrong()`.
I agree we can add `async` when registering scripts that don't have any
dependencies and can never be used as a dependency. This makes most sense
for default core scripts that plugins can use.
> Just to be clear, I'm talking about WP script dependencies generally not
`load-scripts.php` specifically. I think there is good value in adding
`async` and `defer` support to the existing `WP_Scripts` system so that we
can take advantage of them now.
Yes but `load-scripts.php` is an integral part of how we load scripts.
Using `async` and `defer` will have to pull a script out of there (prevent
concatenation) and break the execution order. We can't do that for any of
the default scripts, see the previous comment.
> Since you noted that less than 25% of the Web is on HTTP/2, I don't
think we should let it be the blocker for us to encourage best practices
now for script loading for themes and plugins via `async` and `defer`.
HTTP/2 definitely won't be available before Gutenberg.
Yep, I realise that. Refactoring how we load scripts will slow down 3/4 of
the sites currently. However looking at the speed HTTP/2 is being
implemented, that number will be quite lower in six months, and possibly
be less than 50% by the end of the year.
I also agree with @mor10 that implementing it will give another push to
faster switching to HTTP/2 everywhere.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12009#comment:50>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list