WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 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

Change History (1)

#1 @ocean90
4 years ago

  • Component changed from General to Script Loader
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Type changed from feature request to enhancement

Hello @developersq, welcome to our Trac!

Thanks for your request, we're already tracking this enhancement in #12009 and #22249.

Note: See TracTickets for help on using tickets.