</>
ValidateHTML

Unnecessary type Attribute on script

Before HTML5, <script> needed type="text/javascript" to declare its language. HTML5 made JavaScript the default, so the attribute now says nothing the browser did not already assume. Writing it is harmless but pointless, and it hides the cases where type does carry meaning.

Find this error in your own code. Paste your HTML or enter a URL, free and instant.Open the validator
54.7%
of sites tested

How common is this error?

We ran this validator over the home page of the Tranco top 5,000 websites in August 2026. 1,452 of the 2,655 sites we could reach hit it. That makes it the 2nd most common HTML problem we found, across 10,288 occurrences. See the full study.

Most frequent wording: "type" attribute is unnecessary for javascript resources

Why It Matters

No runtime effect: the script loads either way. The cost is noise. Because type="text/javascript" is so common, readers stop reading the attribute at all, and then miss type="module" or type="application/ld+json", where the value changes how the browser treats the block entirely. It appeared on 54% of the sites we measured.

Common Causes

  • Templates and snippets carried over from an XHTML or HTML 4 codebase, where the attribute was required.
  • Third-party embed code that still ships the attribute for compatibility with very old browsers.
  • CMS themes whose <head> partial has not been revisited since HTML5 landed.

Code Examples

Invalid
<script type="text/javascript" src="/app.js"></script>
<script type="text/javascript">
  console.log("hello");
</script>
Valid
<script src="/app.js"></script>
<script>
  console.log("hello");
</script>

<!-- type still matters here -->
<script type="module" src="/app.mjs"></script>
<script type="application/ld+json">{"@context":"https://schema.org"}</script>

How to Fix

  • 1Delete type="text/javascript" and type="application/javascript". They are the default.
  • 2Keep type="module": it changes the script to an ES module, with deferred execution and its own scope.
  • 3Keep any non-JavaScript type such as application/ld+json or text/template. The browser will not execute those, which is the point.
  • 4Search your templates for type="text/javascript" rather than fixing them one page at a time; it is usually a copy-paste that spread.

Frequently Asked Questions

Does removing the type attribute break older browsers?
No browser still in use requires it. Every browser that supports HTML5 defaults to JavaScript, and browsers old enough to need the declaration cannot run modern JavaScript anyway.
When should a script keep its type attribute?
Whenever the value is not JavaScript. type="module" enables ES modules with deferred execution and module scope, and types like application/ld+json or text/x-template deliberately stop the browser from executing the block.
Is this an error or a warning?
A warning. The markup is perfectly valid HTML; the attribute is simply redundant. It is worth removing for clarity, but nothing breaks if you leave it.

Check Your HTML Now

Our validator detects this error automatically and shows the exact line number.

Open HTML Validator

Related HTML Errors

← View all HTML errors