# Bad value X for attribute “type” on element “script”: A JavaScript MIME type must not contain any characters after the subtype.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-type-on-element-script-a-javascript-mime-type-must-not-contain-any-characters-after-the-subtype
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `type` attribute of a `<script>` element has extra text after its JavaScript MIME type, such as a `; charset=utf-8` parameter or a piece of another attribute.

When a `<script>` has a `type`, the HTML standard tells browsers to run it as JavaScript only if the value is exactly a JavaScript MIME type like `text/javascript`. Letter case and surrounding spaces don't matter, but parameters aren't allowed. Any other value turns the element into a data block, which the browser never runs. So a `<script>` with `src` often gets a second error too: data blocks can't have a `src` attribute.

There are two common causes. Older code sometimes copied `; charset=utf-8` from an HTTP `Content-Type` header, where parameters are allowed, into the `type` attribute, where they aren't. Or someone typed `text/javascript" async="async` into a CMS field or plugin setting that fills in `type`, hoping to add a second attribute. The template escaped the quotes as `&quot;`, so `async` stayed inside the `type` value.

For JavaScript, remove `type`. The default is already `text/javascript`, and the validator reports an explicit one as unnecessary. Write other options like `async` or `defer` as separate attributes. If the script file needs a declared encoding, set it in the `Content-Type` header the server sends for that file.

## Invalid example

```html
<script src="/js/app.js" type="text/javascript; charset=utf-8"></script>
<script src="/js/stats.js" type="text/javascript&quot; async=&quot;async"></script>
```

## Valid example

```html
<script src="/js/app.js"></script>
<script src="/js/stats.js" async></script>
```
