HTML nomodule Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The nomodule attribute is a Boolean on <script>. Browsers that support ES modules ignore scripts with nomodule. Older browsers that do not support modules still run them — so you can ship a classic fallback next to type="module".

Typical pattern: modern browsers load the module; legacy browsers skip type="module" (unknown type) and execute the nomodule script instead. Not deprecated — still the standard progressive-enhancement approach for modules.

Baseline · Widely available.

Not deprecated and not experimental. Stable in modern browsers; used so you can support older ones with a fallback.

Boolean — presence turns it on.

nomodule="false" does not disable it. Omit the attribute when the script should run in module-capable browsers.

HTML Syntax

syntax.html
<script type="module" src=" modern.js"></script>
<script nomodule src=" fallback.js"></script>

Write nomodule alone on the classic fallback. Module browsers skip it; legacy browsers run it.

Attribute Values

Boolean attribute — no value list. Behavior by browser capability:

SetupWhat happensTry it
type="module"Runs in module-capable browsers; ignored by older onesTry it
nomodule presentSkipped where modules work; runs as classic script elsewhereTry it
Inline nomoduleSame skip/run rules without an external srcTry it
Both togetherExactly one path should execute in a given browserTry it

Live Preview

This page detects whether your browser supports modules, then shows which of the two demo scripts would run.

Detection

Uses "noModule" in HTMLScriptElement.prototype (same idea as MDN’s module fallback).

This browser

Checking…

<script type="module" src="main.js"></script>
<script nomodule src="fallback.js"></script>

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Module Script + nomodule Fallback

MDN’s classic progressive-enhancement pattern for external files.

HTML
<script type="module" src="main.js"></script>
<script nomodule src="fallback.js"></script>
Try It Yourself

How It Works

  1. type="module" loads modern ES module code.
  2. nomodule marks the classic fallback for older browsers.
  3. Module browsers run main.js and skip fallback.js.
  4. Legacy browsers ignore type="module" and run fallback.js.

Example 2 — Inline Module + Inline Fallback

Same rules without external files — useful for tiny demos.

HTML
<p id="status">Waiting for script…</p>

<script type="module">
  document.getElementById("status").textContent =
    "Ran type=module (this browser supports modules).";
</script>

<script nomodule>
  document.getElementById("status").textContent =
    "Ran nomodule fallback (no ES module support).";
</script>
Try It Yourself

How It Works

  1. Two inline scripts — one module, one nomodule.
  2. Only one updates the status text in a given browser.
  3. Modern browsers execute the module block and skip nomodule.
  4. Try It Yourself reloads the pair in a clean document.

Example 3 — Feature Check with noModule

Reflect the attribute in JavaScript and explain what this browser would choose.

HTML
<p id="info"></p>
<script>
  var supportsModules = "noModule" in HTMLScriptElement.prototype;
  document.getElementById("info").textContent = supportsModules
    ? "Modules supported — a nomodule script would be skipped."
    : "No module support — a nomodule script would run.";
</script>
Try It Yourself

How It Works

  1. noModule on the prototype appears in module-capable engines.
  2. true path means this browser would skip nomodule scripts.
  3. false path means the fallback would execute.
  4. Optional: HTMLScriptElement.supports("module") where available.

Edge Cases & Pitfalls

Most mistakes are putting nomodule on the wrong script or expecting both files to run.

pair

Do not put nomodule on the module script

Mark only the classic fallback. The modern file uses type="module" alone.

boolean

nomodule="false" still skips in module browsers

Presence means on. Remove the attribute to allow execution everywhere (classic script).

double

Only one path should run

In a correct pair, you never execute both main.js and fallback.js in the same browser.

build

Fallback must be classic JS

Do not put import/export in the nomodule file — older engines need a bundled classic script.

today

Many sites can ship modules only

If your audience is modern-only, you may skip nomodule. Keep it when you still need a legacy path.

Browser Support

nomodule is an HTML attribute on script elements. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

nomodule

Supported wherever ES modules are. Module browsers skip nomodule scripts; older browsers without modules still execute them as classic scripts.

96% Global support (approx.)
Google Chrome 61+
Full support
Mozilla Firefox 60+
Full support
Apple Safari 11+
Full support
Microsoft Edge 16+
Full support
Opera 48+
Full support
Samsung Internet 8+
Full support
Internet Explorer Ignores type=module; runs nomodule
Fallback path
nomodule Widely supported

Bottom line: Safe to use for module + classic dual delivery. Module-capable browsers skip nomodule; legacy browsers run the fallback.

Key Takeaways

  • Role: mark classic scripts that module browsers should skip.
  • Pair with type="module" for modern code.
  • Boolean: present = skip in module engines.
  • Not deprecated — still the standard module fallback pattern.

One line: nomodule is the classic fallback that module browsers ignore.

Frequently Asked Questions

It is a Boolean attribute on script. Browsers that support ES modules ignore scripts marked with nomodule. Older browsers that do not understand modules will still run those scripts as a fallback.
Put your modern code in <script type="module" src="main.js"> and a classic bundle in <script nomodule src="fallback.js">. Module-capable browsers run only the first; legacy browsers run only the second.
No. It is a current, Baseline widely available attribute for progressive enhancement of module scripts.
No. Boolean attributes are on when present. To run a script in all browsers, omit nomodule (and do not use type="module" if you need classic behavior everywhere).
Yes. Inline <script nomodule>…</script> is skipped in module-capable browsers and executed in browsers that do not support modules.
Check "noModule" in HTMLScriptElement.prototype, or use HTMLScriptElement.supports("module") where available.

Next: nonce

Allow inline scripts and styles under a Content-Security-Policy.

nonce tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful