Skip to content

Remove unnecessary type="text/javascript" attributes from <script> tags (W3C validation warning)#805

Merged
masteradhoc merged 4 commits intoWordPress:masterfrom
masteradhoc:script-types
Feb 24, 2026
Merged

Remove unnecessary type="text/javascript" attributes from <script> tags (W3C validation warning)#805
masteradhoc merged 4 commits intoWordPress:masterfrom
masteradhoc:script-types

Conversation

@masteradhoc
Copy link
Collaborator

@masteradhoc masteradhoc commented Feb 22, 2026

Step to achieve #63

What?

This PR removes redundant type="text/javascript" attributes from inline <script> tags across the Two-Factor plugin to resolve W3C validation warnings.


Why?

Under HTML5, text/javascript is the default value for <script> elements. Explicitly defining it is unnecessary and produces validation warnings such as:

“The type attribute is unnecessary for JavaScript resources.”

Removing the attribute improves standards compliance and eliminates avoidable validation noise without changing behavior.


How?

All instances of:

<script type="text/javascript">

were replaced with:

<script>

Updated files:

  • class-two-factor-core.php
  • providers/class-two-factor-backup-codes.php
  • providers/class-two-factor-email.php
  • providers/class-two-factor-totp.php

No JavaScript logic or execution flow was modified. Only the redundant attribute was removed.


Testing Instructions

  1. Apply the patch.
  2. run pages through validator
  3. make sure we dont have this error
    "The type attribute is unnecessary for JavaScript resources warning."

Screenshots or screencast

Not applicable (markup-only standards compliance update).


Changelog Entry

Changed - Removed unnecessary type="text/javascript" attributes from script tags for HTML5 compliance.

@github-actions
Copy link

github-actions bot commented Feb 22, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: masteradhoc <masteradhoc@git.wordpress.org>
Co-authored-by: georgestephanis <georgestephanis@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@masteradhoc masteradhoc added this to the 0.16.0 milestone Feb 22, 2026
@masteradhoc masteradhoc self-assigned this Feb 22, 2026
Copy link
Collaborator

@georgestephanis georgestephanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's optional in html5 by my understanding, and if omitted is the fallback to text/javascript mime type. Probably safe to drop, but there's also no real harm in having it. I'm fine with either.

@masteradhoc
Copy link
Collaborator Author

@georgestephanis tried to be inline with WP 7.0 where this will get dropped as well :) https://core.trac.wordpress.org/changeset/61440

@masteradhoc masteradhoc merged commit 5d6e459 into WordPress:master Feb 24, 2026
29 checks passed
@masteradhoc masteradhoc deleted the script-types branch February 24, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants