Skip to main content

HTML Guide

A “script” element with a “defer” attribute must not have a “type” attribute with the value “module”.

The combination of type="module" and defer is not allowed. The type="module" attribute itself implies that the script should be executed in a deferred way, hence using the defer attribute is unnecessary and invalid.

Steps to Fix the Issue:

  1. Remove the defer Attribute: When you use type="module", you should not include the defer attribute since module scripts defer automatically.

Incorrect Code:

<script type="module" defer src="example.js"></script>

Corrected Code:

<script type="module" src="example.js"></script>

Learn more:

Related W3C validator issues