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

WordPress Trac noreply at wordpress.org
Thu Apr 27 22:32:22 UTC 2023


#12009: Add support for HTML 5 "async" and "defer" attributes
--------------------------------------+--------------------------
 Reporter:  Otto42                    |       Owner:  10upsimon
     Type:  enhancement               |      Status:  assigned
 Priority:  high                      |   Milestone:  6.3
Component:  Script Loader             |     Version:  4.6
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------

Comment (by 10upsimon):

 We have completed an initial implementation for this ticket and just
 opened a [https://github.com/WordPress/wordpress-develop/pull/4391 new
 pull request for feedback]. For background on the approach we’ve taken,
 you can reference [https://make.wordpress.org/core/2022/12/09/enhancing-
 the-scripts-api-with-a-loading-strategy the feature proposal] that
 @adamsilverstein posted last December.

 The approach we’ve taken will enhance the Scripts API to allow developers
 to declare intended loading strategies for scripts (and inline scripts)
 during registration by replacing the current `$in_footer` param with a new
 `$args` param of type array that supports declaring both `in_footer` and
 `strategy` keys in `wp_register_script` and `wp_enqueue_script` functions.
 This change is fully backward compatible with the previous function
 signatures.

 The logic automatically handles resolving conflicting strategies in the
 dependency tree so that scripts will be printed using the most eligible
 strategy to avoid breaking script execution. This should cover all of the
 concerns @azaozz has helpfully mentioned in
 [https://core.trac.wordpress.org/ticket/12009#comment:75 this comment] and
 elsewhere.

 While this work does add attributes to the script tags in order to enable
 a loading strategy, it does not allow direct control of custom script
 attributes to ensure that dependencies always maintain their correct
 loading order. This has been discussed in a few comments within this Trac
 ticket.

 I'm working on an update post with additional context to publish on the
 Make WordPress Core blog soon.

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


More information about the wp-trac mailing list