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

WordPress Trac noreply at wordpress.org
Mon Mar 5 15:03:35 UTC 2018


#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:  4.6
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+------------------------------

Comment (by azaozz):

 > async / defer is now considered best practice...

 Correct me if I'm wrong but both `async` and `defer` don't make much
 difference for scripts at the end of the HTML document (in the footer).

 In addition they don't make sense when scripts are concatenated, i.e. in
 production.

 In addition `async` cannot be used if the script has dependencies or is
 used as dependency for another script.

 So, what are the user cases for these attributes with the current script-
 loader?

 As far as I see the only thing we can do is add `defer` to the script tag
 that loads the concatenated scripts in the footer. We probably can add
 `defer` when outputting single script tags for scripts that are enqueued
 for the footer. Not sure if either of these will make any significant
 difference :)

 Also thinking we should have another look at script-loader. Modern
 JavaScript is about modules and building (pre-concatenating). The current
 script-loader's dependency model and JIT concatenating may not be
 necessary.

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


More information about the wp-trac mailing list