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

WordPress Trac noreply at wordpress.org
Mon Mar 5 19:20:53 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:
---------------------------+-----------------------------
Changes (by westonruter):

 * milestone:  Awaiting Review => Future Release


Comment:

 In terms of [attachment:async_defer_scripts_new.2.patch], and as @Otto42
 [https://core.trac.wordpress.org/ticket/12009#comment:16 commented],  I
 think that we should be getting away from adding new positional parameters
 to `wp_enqueue_script()`. Already they are hard to remember. Adding two
 additional ones will just make it harder to use. I suggest we rework
 `wp_register_script()` to allow passing the `$deps`, `$ver`, and
 `$in_footer` as part of an `$args` array, which would allow for them all
 to be omitted (since they are optional) as well as to easily allow for new
 parameters including `async`, `defer`, and `module`. For example:

 {{{#!php
 <?php
 wp_register_script( 'foo', plugins_url( 'foo.js', __FILE__ ), array(
     // Look ma, no $deps or $ver!
     'in_footer' => true,
     'async' => 'true',
     // ... 'defer', 'module', etc.
 ) );
 }}}

 Same pattern can be applied to `wp_enqueue_script()`.

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


More information about the wp-trac mailing list