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

WordPress Trac noreply at wordpress.org
Thu Jul 7 17:13:28 UTC 2016

#12009: Add support for HTML 5 "async" and "defer" attributes
 Reporter:  Otto42         |       Owner:  azaozz
     Type:  enhancement    |      Status:  reopened
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Script Loader  |     Version:  trunk
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
Changes (by azaozz):

 * keywords:  has-patch needs-testing =>


 FTR `async` and `defer` do pretty much the same thing: begin to download
 the script in parallel immediately. The difference is that each `async`
 script executes after it has finished downloading. It’s likely that
 `async` scripts are not executed in the order in which they occur in the
 page. The `defer` scripts are guaranteed to be executed in the order they
 occur in the page (https://webkit.org/blog/1395/running-scripts-in-

 Then logically:
 - `async` and `defer` make little sense when scripts are concatenated.
 - `async` scripts cannot be used as dependencies.
 - `defer` scripts can be used as dependencies only if all dependent
 scripts also have the `defer` attribute.
 - Neither `async` nor `defer` scripts can have any inline scripts.

 In that terms the above patch is a good start but is missing a lot. Looks
 like this will be quite complex to implement in WP_Scripts. Perhaps it can
 be made a bit simpler by supporting these attributes only for third party
 scripts, etc.

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

More information about the wp-trac mailing list