Skip to content

Commit fc2e9e3

Browse files
committed
doc: @top-level-await
1 parent bf97b13 commit fc2e9e3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

content/api/metadata-block.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ If supplied, the question mark icon in the user scripts list will link to this.
253253

254254
If supplied, the home icon in the user scripts list will link to this.
255255

256-
257256
### @unwrap
258257

259258
Since VM2.13.1.
@@ -266,3 +265,12 @@ The [`@inject-into`](#inject-into) key is supported as usual.
266265
A typical use case is direct access to global page variables declared as `const` or `let`. In a standard userscript you would have to create a `script` element yourself explicitly by using `document.createElement` or [`GM_addElement`](/api/gm/#gm_addelement), then transfer the result via a `CustomEvent` or `unsafeWindow.foo`.
267266
268267
Another use case is migration from other extensions that run your JavaScript code as is, without userscript API.
268+
269+
### @top-level-await
270+
271+
Since VM2.19.2.
272+
273+
Enables top-level `await` in your script. Useful when the rest of your script's code depends on some external event e.g. when waiting for an element using MutationObserver or fetching data from network.
274+
275+
* Avoid using it to import dependencies that should always run; prefer using `@require` and `@resource`.
276+
* Can't be used with `@unwrap`.

0 commit comments

Comments
 (0)