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.
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
<script type="text/javascript" src="/app.js"></script>
<script type="text/javascript">
console.log("hello");
</script><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?
When should a script keep its type attribute?
Is this an error or a warning?
Check Your HTML Now
Our validator detects this error automatically and shows the exact line number.
Open HTML ValidatorRelated HTML Errors
Missing DOCTYPE Declaration
A missing DOCTYPE forces browsers into quirks mode, breaking your layout. Learn why <!DOCTYPE html> is required and how to fix inconsistent rendering fast.
Missing Charset Declaration
A missing charset declaration turns accents and emoji into garbled text. Learn why declaring UTF-8 is essential and how to fix encoding issues in your HTML.
Deprecated HTML Elements
Deprecated HTML elements like center, font, and marquee signal outdated code. See the full list and the modern CSS replacements that fix every warning.