← Back to release summary

Top-level await

Category
JavaScript
Type
New or changed feature
Status
Enabled by default (Chrome 89)
Intent stage
Shipped

WPT details: In test262: https://github.com/tc39/test262/tree/master/test/language/module-code/top-level-await Changes to module script timing in WPT in various places. (See the TopLevelAwait virtual WPT suite.)

Summary

Allow the `await` keyword at the top-level within JavaScript modules.

Motivation

Allows more seamless integration of async calls into the module loading process. Today this is accomplished by wrapping modules in async functions, but this pushes complexity into dependent modules and exposes implementation details.

Standards & signals

Ecosystem

Docs: https://docs.google.com/document/d/15jxKo7kqj0bRHcnSmwjhj1XaWH1AXRDtYPiJHluCSiA/edit

Explainers: https://v8.dev/features/top-level-await https://github.com/tc39/proposal-top-level-await

View on chromestatus.com