Opened 8 years ago
Closed 8 years ago
#38137 closed enhancement (duplicate)
Add support to add attributes in wp_register_script() and wp_register_style()
Reported by: | developersq | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | |
Focuses: | Cc: |
Description
Both <link>
and <script>
tags support extra attributes to how and when to load the style or script.
Current implementation of wp_register_script()/wp_enqueue_script() and wp_register_style()/wp_enqueue_style() do not have any option to add extra attributes.
Most useful scenario to use this feature(s) in case of JavaScript <script>
is to easily add 'async' or 'defer' attributes when needed. Also, in case of CSS <link>
, ability to add 'media' and 'rel' attributes. Here, the use of 'rel' is really important to enhance the performance and user experience for the webpage.
https://developer.mozilla.org/en/docs/Web/HTML/Element/script
https://developer.mozilla.org/en/docs/Web/HTML/Element/link
http://www.w3schools.com/tags/att_link_rel.asp
Hello @developersq, welcome to our Trac!
Thanks for your request, we're already tracking this enhancement in #12009 and #22249.