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

WordPress Trac noreply at wordpress.org
Wed Apr 27 19:09:14 UTC 2016


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

Comment (by ericlewis):

 I've refreshed the patch in attachment:22249.6.diff, comments inline.

 @ocean90 said:

 > IMO `get_script_attributes()` shouldn't return the `$src` value. I'd
 call it `get_(script)_additonal_attributes()`. That would solve all the
 special cases which makes the code a bit too complex right now.

 This implementation would make preserving the existing attribute order of
 `type` and then `src` cumbersome, so the current implementation seems like
 an okay amount of complex.

 > This shouldn't go in without support for styles. Note that `WP_Styles`
 has already `_css_href( $src, $ver, $handle )`.

 attachment:22249.6.diff has the beginning of an implementation, but it's
 complicated.

 We're planning on adding an `$args` parameter to `wp_register_script()`,
 which holds the extra attributes for the script. `wp_enqueue_style()`
 already accepts the `$media` value which it shoves in to the `$args`
 parameter in the underlying `WP_Scripts->add()` call.

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


More information about the wp-trac mailing list