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

WordPress Trac noreply at wordpress.org
Wed Jul 6 08:22:09 UTC 2016


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

 * status:  closed => reopened
 * version:   => trunk
 * resolution:  worksforme =>


Comment:

 Is there any interest in reviving this topic? I was going to create a
 ticket, but found this ticket, so I'll submit my patch here. Browser
 support seemed to be a big part of the debate previously and shouldn't be
 a concern now.

 The lack of options for using the async and/or defer attributes with
 script elements is a bit of a pain in WordPress, which has resulted in
 some users coming up with dirty/hackish ways of doing so, such as using
 the {{{clean_url}}} filter to add the attribute(s).

 The {{{script_loader_tag}}} '''solves this to a degree''', but it would be
 better to specify this option at the time of loading the script (the
 filter has other uses as well).

 This patch adds two new arguments for {{{wp_enqueue_script}} and outputs
 the results in the printed <script> tag, and both default to false.

 Using both tags simultaneously may be beneficial for legacy browser
 support, and some third-party documentation (Google Maps JS API for
 example) recommends using the attributes together.

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


More information about the wp-trac mailing list