[wp-trac] [WordPress Trac] #51447: "type" attribute is unnecessary for JavaScript resources.

WordPress Trac noreply at wordpress.org
Fri Nov 6 14:28:01 UTC 2020


#51447: "type" attribute is unnecessary for JavaScript resources.
-------------------------------+-------------------------------------------
 Reporter:  mhimon             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Script Loader      |     Version:  5.5.1
 Severity:  minor              |  Resolution:  duplicate
 Keywords:  reporter-feedback  |     Focuses:  javascript, coding-standards
-------------------------------+-------------------------------------------
Changes (by SergeyBiryukov):

 * status:  new => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


Comment:

 Hi there, thanks for the ticket!

 Just to clarify the reply above, you can remove the `type` attributes with
 a snippet like this:
 {{{
 function mytheme_register_support() {
     add_theme_support( 'html5', array( 'script', 'style' ) );
 }
 add_action( 'after_setup_theme', 'mytheme_register_support' );
 }}}

 This is mentioned in [https://make.wordpress.org/core/2019/10/15
 /miscellaneous-developer-focused-changes-in-5-3/ Miscellaneous Developer
 Focused Changes in 5.3]
 > In HTML5, the `type` attribute is not required for the `<script>` and
 `<style>` tags. Including the attribute on these tags
 (`type="text/javascript"`, for example) will trigger a validation warning
 in HTML validation tools.
 >
 > In WordPress 5.3, two new arguments are now supported for the `html5`
 theme feature, `script` and `style`. When these arguments are passed, the
 `type` attribute will not be output for those tags.

 See #42804 for more details.

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


More information about the wp-trac mailing list