[wp-trac] [WordPress Trac] #12009: Add support for HTML 5 "async" and "defer" attributes

WordPress Trac noreply at wordpress.org
Fri Mar 9 05:02:46 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 westonruter):

 Replying to [comment:50 azaozz]:
 > 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.

 Something else to clarify here is that I think @mor10 is primarily eyeing
 use of `async` and `defer` on the '''frontend''' where `wp-admin/load-
 scripts.php` is not used (or at least I've never seen it used), and in
 which theme/plugin scripts are not included for concatenation anyway
 (since they are not `in_default_dir`).

 But in the admin this is also where I think service workers should be used
 to cache assets instead (as I noted above), and here too this would allow
 for the scripts to cease being concatenated and so there would be no need
 to pull out async/defer scripts.

 I see value in pushing forward with `async`/`defer` support in core for
 the immediate term, as these are standard performance  best practices
 today. They'd be used primarily by themes and plugins: I can see some core
 scripts like `comment-reply.js` get `async`, but we'd just need to work
 into the script-loader logic to strip `async` from any script that is a
 dependency for another script.

 Then as HTTP/2 and service workers become more well supported we can
 abandon `load-scripts.php` entirely and potentially make async/defer
 conditional based on whether HTTP/2 is available, for example.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/12009#comment:54>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list