Make WordPress Core

Opened 2 months ago

Last modified 8 weeks ago

#51837 new defect (bug)

Adding `add_theme_support` for html5 for scripts, does not remove the type attribute from `wp-emoji-release.min.js`

Reported by: kanlukasz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3
Component: Script Loader Keywords: needs-patch
Focuses: Cc:


This is a follow-up to #42804.

Using: add_theme_support('html5', ['script', 'style']); removes the type attribute from my custom scripts but does not remove it from the default wp-emoji-release.min.js

<script src="https://example.com/wp-includes/js/wp-emoji-release.min.js?ver=5.5.3" type="text/javascript" defer=""></script>

Change History (1)

#1 @peterwilsoncc
8 weeks ago

  • Version changed from 5.5.3 to 5.3

Hello @kanlukasz and welcome to trac!

I've been able to confirm the report, the script is loaded using JavaScript in emoji-loader.js and the theme support setting is not passed to the JavaScript to determine if the type attribute should be included.

From /src/js/_enqueues/lib/emoji-loader.js:

function addScript( src ) {
        var script = document.createElement( 'script' );

        script.src = src;
        script.defer = script.type = 'text/javascript';
        document.getElementsByTagName( 'head' )[0].appendChild( script );

At a quick glance the same issue applies to src/js/_enqueues/lib/zxcvbn-async.js if it's loaded on the front-end of a site. Some external libraries may include the type too but unfortunately they are out of WordPress's control.

Note: See TracTickets for help on using tickets.