# A “script” element with “type=module” must not have a “defer” attribute.

> Canonical HTML version: https://rocketvalidator.com/html-validation/a-script-element-with-type-module-must-not-have-a-defer-attribute
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `defer` attribute has no effect on `<script>` elements that have `type="module"` because module scripts are already deferred by default.

When a browser encounters `<script type="module">`, it automatically fetches the script in parallel with HTML parsing and executes it after the document has been parsed. This is the same behavior that `defer` provides for classic scripts. Adding `defer` to a module script is redundant, and the W3C validator flags it as invalid markup.

Classic scripts (`<script src="...">`) block HTML parsing by default. The `defer` attribute changes that behavior so the script loads in parallel and runs after parsing completes. Module scripts adopted this deferred behavior as their default, so the attribute is unnecessary.

The `async` attribute, on the other hand, *does* have an effect on module scripts. It causes the module to execute as soon as it finishes loading, rather than waiting for parsing to complete.

## Examples

### Invalid: `defer` on a module script

```html
<script type="module" src="app.js" defer></script>
```

### Valid: module script without `defer`

```html
<script type="module" src="app.js"></script>
```

Remove the `defer` attribute. The script will behave exactly the same way, since module scripts are deferred by default.
