The HTML nomodule attribute
Quick answer
The HTML nomodule attribute marks a script to be ignored by browsers that support ES modules. It is used on the <script> element.
Overview
The nomodule attribute marks a script to be ignored by browsers that support ES modules. It applies to the <script> element.
It is the classic module/nomodule pattern: ship <script type="module"> for modern browsers and <script nomodule> as a fallback. In 2026 it is rarely needed, since virtually all browsers support modules.
Syntax
<script nomodule src="legacy.js"></script>
Values
| Value |
|---|
| A boolean attribute — present or absent. |
Best practices
- Declare the character encoding with <meta charset="utf-8"> first in the <head>.
- Load scripts with defer (or as modules) so they do not block parsing.
- Protect third-party resources with integrity and crossorigin (Subresource Integrity).
- Use resource hints like preload deliberately, paired with the right as value.
Frequently asked questions
What does the nomodule attribute do?
Provides a fallback script for legacy browsers.