WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 4 weeks ago

Last modified 4 weeks ago

#51447 closed defect (bug) (duplicate)

"type" attribute is unnecessary for JavaScript resources.

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

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
2 months ago

  • Component changed from General to Script Loader
  • Keywords reporter-feedback added
  • Severity changed from major to 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
4 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to 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 4 weeks ago by SergeyBiryukov (previous) (diff)

#3 @SergeyBiryukov
4 weeks ago

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