Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#51447 closed defect (bug) (duplicate)

"type" attribute is unnecessary for JavaScript resources.

Reported by: mhimon Owned by:
Priority: normal Milestone:
Component: Script Loader Version: 5.5.1
Severity: minor Keywords: reporter-feedback
Cc: Focuses: javascript

Description

Hello,

I got an "HTML" validation issue on my client site. Well, I checked some of my client websites and they all have the same validation error!

https://scontent.fdac10-1.fna.fbcdn.net/v/t1.15752-9/120774202_2703280896605781_6902198684136881457_n.png

update-core.php file content:
You have the latest version of WordPress.
If you need to re-install version 5.5.1, you can do so here:

Thanks :)

Change History (3)

#1 @Hareesh Pillai
6 years ago

  • Component General → Script Loader
  • Keywords reporter-feedback added
  • Severity major → minor

Hello and welcome to trac, @mhimon. Thanks for the report.

This was earlier fixed in #42804.

I could not reproduce this in the Twenty Twenty theme using the latest WordPress version.

Can you help by sharing some more details of your setup - especially how jQuery script is enqueued?

Further, the notice that you see is only a warning - which means the site will continue to work without any issue. Hence, I'm changing the severity of this ticket.

#2 @SergeyBiryukov
6 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

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 ​Miscellaneous Developer Focused Changes in 5.3 dev note:

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.

Last edited 6 years ago by SergeyBiryukov (previous) (diff)

#3 @SergeyBiryukov
6 years ago

  • Focuses coding-standards removed
Note: See TracTickets for help on using tickets.