Top-Level await Playground

Four modules open the warung in the morning: a top-level await in harga.js or the old async IIFE, Bagas slow back from the market, and two modules importing…

Why it matters

Useful for setup code: reading config, opening a connection, loading WASM, picking an implementation by what the browser can do, all guaranteed done before another module uses it. But because importers are held back too, one slow await in a widely used module can hold up the whole app’s startup, and two modules waiting on each other can hang with no error.

The key idea

Top-level await makes the module async, and every importer waits with it

Common mistakes

Try it in this playground