# A “script” element with a “type” attribute whose value is neither a JavaScript MIME type, “module”, “importmap”, nor “speculationrules” (i.e., a data block) must not have a “src” attribute.

> Canonical HTML version: https://rocketvalidator.com/html-validation/a-script-element-with-a-type-attribute-whose-value-is-neither-a-javascript-mime-type-module-importmap-nor-speculationrules-i-e-a-data-block-must-not-have-a-src-attribute
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `src` attribute is invalid on a `<script>` element whose `type` marks it as a data block, because the data lives in the element itself and there is nothing to fetch from elsewhere.

When the `type` attribute is anything other than a JavaScript MIME type, `module`, `importmap`, or `speculationrules`, the browser treats the element as a data block: inline content that other scripts on the page can read, but that is never downloaded or run. The most common example is `application/ld+json` structured data. The whole point of a data block is that it carries its content between the opening and closing tags, so pointing `src` at an external file makes no sense and is not allowed.

This usually happens when the `type` is set for a data block but the markup was copied from a real external script that still carries its `src`.

## Examples

### Invalid: `src` on a data block

```html
<script type="application/ld+json" src="https://example.com/data.json"></script>
```

### Valid: data block with inline content

```html
<script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "Organization",
    "name": "Example"
  }
</script>
```

Remove the `src` attribute and place the data inline. If the file really is a script to load and run, fix the `type` value instead: use a JavaScript MIME type, `module`, or omit the attribute entirely.
