v156 · deferred evaluation · timing

Syntax and timing

Import a deferred module, prove its top-level code has not run, then trigger it with a single property access — watching the module's own side-effect log and the timestamps flip the moment you touch the namespace.

To run this for real

import defer is a V8 staged feature. Chrome does not yet parse the grammar by default. To enable the real path, relaunch Chrome (or Chrome Canary) from a terminal with the V8 flag:

  1. --js-flags=--js-defer-import-eval (the exact V8 feature flag, js_defer_import_eval), or
  2. --js-flags=--harmony to enable all staged JavaScript features.

There is no chrome://flags toggle and no --enable-blink-features name for this — it is a V8-side language feature, not a Blink one. The panel below reports what this browser actually does.

Does this browser parse import defer?

Checking…

Load deferred, then trigger evaluation

step 1module imported & parsednot yet
after import, before accesstop-level evaluated?
after first property accesstop-level evaluated?
Run the support check, then load the module.

module side-effect log

The module and the page

The imported module (modules/defer-entry.js) re-exports a deferred namespace so the page can hold it untouched:

// defer-entry.js
import defer * as ns from "./expensive.js";
export { ns };
export function firstAccess() { return ns.ready; }   // this GET triggers evaluation

expensive.js pushes a record to globalThis.__importDeferLog from its top level, so "has it run?" is answered by data, not narration.

see also