ES Modules and Live Bindings vs Preload Scanner and fetchpriority Attribute
Nested ES module imports cannot be discovered by the HTML preload scanner without modulepreload hints.
Structured Comparison Matrix
| Dimension | ES Modules and Live Bindings | Preload Scanner and fetchpriority Attribute |
|---|---|---|
| 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. |
| Maturity & Domain | Baseline · Widely · JS Runtime Chrome 61+ · Firefox 60+ · Safari 11+ | Baseline · Newly · Network & Performance Chrome 101+ · Firefox 132+ · Safari 17.2+ |
| Prerequisites | Foundational primitive | |
| 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. |
Engine Mechanics & Trade-Offs
ESM links imports as read-only indirect pointers into the exporting module's LexicalEnvironment before executing a single line of module code.
Key Pitfalls: Circular TDZ Crashes: Reading an imported const before the exporting module finishes evaluating throws ReferenceError. Unbundled Waterfall Latency: Serving 200 raw ESM files over HTTP/2 without modulepreload stalls First Interactive behind serial round-trips.
fetchpriority adjusts resource priority before the first Layout pass.
Key Pitfalls: Client-injected LCP images: The Preload Scanner cannot see images mounted dynamically by React/SPA bundles until an Event Loop task executes JS, by which time your LCP budget is already half-spent. Overusing fetchpriority="high": Marking 10 images as high cancels prioritization benefits and delays critical stylesheets.