# ES Modules and Live Bindings vs Preload Scanner and fetchpriority Attribute

- **Canonical URL:** https://frontend.rocks/vs/es-modules-live-bindings-vs-preload-scanner-hints/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** Nested ES module imports cannot be discovered by the HTML preload scanner without modulepreload hints.

## Comparison Matrix

| Dimension | ES Modules and Live Bindings | Preload Scanner and fetchpriority Attribute |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Baseline · Newly |
| **Domain** | JS Runtime | Network & Performance |
| **Mental Model** | Eliminate stale circular-import snapshots and unlock static tree-shaking—ESM imports wire read-only indirect pointers into the exporter's ModuleEnvironmentRecord. | Speculative HTML scanner discovering critical resources before JS execution, paired with fetchpriority to reorder the HTTP/2-HTTP/3 queue. |
| **Prerequisites** | Execution Context, Lexical Environment, and Call Stack (ModuleEnvironmentRecords extend LexicalEnvironments with cross-module indirect binding slots.) | None |
| **When Not to Use** | When not to use raw unbundled ESM: Never ship hundreds of unbundled node_modules ESM files to production browsers without bundling or <link rel="modulepreload"> hints. | When not to use fetchpriority="high": Never apply it to below-the-fold images or secondary web fonts; for cross-page navigation speedups, use Speculation Rules instead. |

## ES Modules and Live Bindings — Under the Hood
During instantiation, V8 allocates a `ModuleEnvironmentRecord` per module and wires read-only indirect bindings straight to the exporter's slots before execution. Whereas CommonJS `require()` copies a value snapshot at call time, an ESM `import` exposes live updates without allowing reassignment.

1. **Construction**: The loader fetches and parses all static `import` specifiers before running any code.
2. **Instantiation**: The engine allocates a `ModuleEnvironmentRecord` for each module and wires indirect bindings from imports to exports.
3. **Evaluation**: Modules execute post-order (leaves first); top-level `await` pauses parent evaluation until settled.
4. **Network Discovery**: Unlike `<script>` tags spotted by [Preload Scanner Hints](/concepts/preload-scanner-hints), deep ESM imports trigger waterfalls unless declared with `modulepreload`.

```js
// counter.mjs
export let count = 0;
export const increment = () => { count += 1; };

// consumer.mjs
import { count, increment } from './counter.mjs';
increment();
console.log(count); // 1 (live read-only view)
```

## Preload Scanner and fetchpriority Attribute — Under the Hood
Treat the Preload Scanner as an airport baggage advance scout: while the main HTML parser is stuck at security behind a blocking `<script>`, the scanner sprints ahead through the raw byte stream and puts critical luggage on the conveyor belt early.

1. As soon as the first HTML packets arrive, a dedicated thread (Preload Scanner) extracts `<link>`, `<script>`, and `<img>` tags before DOM construction completes for the [Browser Rendering Pipeline](/concepts/browser-rendering-pipeline).
2. By default, Blink queues images at `Low` priority and only promotes in-viewport images to `High` after the first Layout pass.
3. `fetchpriority="high"` assigns `High` priority in the HTTP/2 or HTTP/3 queue immediately upon HTML discovery, while `fetchpriority="low"` demotes carousel slides out of the way.

```html
<!-- Discovered in the first TCP window; queued ahead of deferred scripts -->
<img
  src="/hero-banner.avif"
  width="1200"
  height="640"
  fetchpriority="high"
  decoding="async"
  alt="Dashboard overview"
/>
```

## Interactive Labs & Dissections
- [ES Modules and Live Bindings Lab](https://frontend.rocks/concepts/es-modules-live-bindings/#lab) ([Markdown](https://frontend.rocks/concepts/es-modules-live-bindings.md))
- [Preload Scanner and fetchpriority Attribute Lab](https://frontend.rocks/concepts/preload-scanner-hints/#lab) ([Markdown](https://frontend.rocks/concepts/preload-scanner-hints.md))

## Related Architecture Autopsies
- [Autopsy #04: The Zombie Bundle After a Production Deployment](https://frontend.rocks/autopsies/zombie-bundle-after-deploy/) ([Markdown](https://frontend.rocks/autopsies/zombie-bundle-after-deploy.md)): Active tabs throw ChunkLoadError or corrupt local IndexedDB state after a production deploy.

## Primary Sources
- https://tc39.es/ecma262/#sec-resolveexport
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
- https://web.dev/articles/fetch-priority
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority
