[wp-trac] [WordPress Trac] #22249: Add ability to set or remove attributes on enqueued scripts and styles.

WordPress Trac noreply at wordpress.org
Tue Jan 2 12:19:51 UTC 2018


#22249: Add ability to set or remove attributes on enqueued scripts and styles.
-------------------------------------------+-----------------------------
 Reporter:  ryanve                         |       Owner:
     Type:  enhancement                    |      Status:  assigned
 Priority:  normal                         |   Milestone:  Future Release
Component:  Script Loader                  |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  early has-patch needs-testing  |     Focuses:
-------------------------------------------+-----------------------------

Comment (by mihai2u):

 I've tested the script's ability to add async and defer:
 {{{#!php
 <?php
 wp_enqueue_script( 'twentyseventeen-skip-link-focus-fix',
 get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '1.0',
 true, array( 'async' => 'async', 'defer' => 'defer' ) );
 }}}

 The generated script tag included the necessary attributes:
 {{{
 <script type='text/javascript' src='http://wordpress-develop.local/wp-
 content/themes/twentyseventeen/assets/js/skip-link-focus-fix.js?ver=1.0'
 async='async' defer='defer'></script>
 }}}

 The update to an array attribute inside wp_register_style and
 wp_enqueue_style I've seen in 22249-3.diff was not present anymore in the
 22249.7.diff, hence I didn't find a way to test adding / overriding the
 stylesheet tag attributes.

 I think this should move forward as it's a much welcomed addition to avoid
 having to manipulate the strings using the script tag filter whenever an
 async or defer attribute is needed.

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


More information about the wp-trac mailing list