Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#38137 closed enhancement (duplicate)

Add support to add attributes in wp_register_script() and wp_register_style()

Reported by: developersq Owned by:
Priority: normal Milestone:
Component: Script Loader Version:
Severity: normal Keywords:
Cc: Focuses:

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
10 years ago

  • Component GeneralScript Loader
  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed
  • Type feature requestenhancement

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.