Re:Top-level await in JavaScript is a footgun
by bmeck on Wednesday September 14, 2016 @01:24PM
(#12499225)
top level await is only possible in grammar w/ `await` as a reserved word. This is limited to Modules (type=module) and async functions. You can't put it in your click handler or random Script like the examples you gave.
This looks like it would allow some interesting new patterns in web programming, though at the expense of wreaking havoc with traditional execution models.
For example, await in event handlers:
Is the event object still valid when doAnotherThing is called?Or await in script blocks:
Look ma, I stalled the page load with no synchronous XHR!