Top-level await in JavaScript is a footgun
gist.github.com
Top-level await in JavaScript is a footgun
1–10 of 115 posts
Re: Top-level await in JavaScript is a footgun
#2Is that right? `await` is non-blocking, no?
Re: Top-level await in JavaScript is a footgun
#3> Even assuming all goes well, you've prevented yourself from doing any other work, like rendering views that don't depend on that data. Is that right? `await` is non-blocking, no?
Re: Top-level await in JavaScript is a footgun
#4> Even assuming all goes well, you've prevented yourself from doing any other work, like rendering views that don't depend on that data. Is that right? `await` is non-blocking, no?
Re: Top-level await in JavaScript is a footgun
#5> Even assuming all goes well, you've prevented yourself from doing any other work, like rendering views that don't depend on that data. Is that right? `await` is non-blocking, no?
Re: Top-level await in JavaScript is a footgun
#6> Even assuming all goes well, you've prevented yourself from doing any other work, like rendering views that don't depend on that data. Is that right? `await` is non-blocking, no?
Re: Top-level await in JavaScript is a footgun
#7 > A lot of people misunderstood Top-level await is a footgun, including me.
https://gist.github.com/Rich-Harris/41e8ccc755ea232a5e7b88de...Re: Top-level await in JavaScript is a footgun
#8> Even assuming all goes well, you've prevented yourself from doing any other work, like rendering views that don't depend on that data. Is that right? `await` is non-blocking, no?
If your app is shipped as a single bundle this means your entry point would be unable to run anything while dependencies are awaiting if you use `import` declarations. If your app places runtime dependent imports into a dynamic import like using `import()` as a function, it would not be suspended while waiting.
Re: Top-level await in JavaScript is a footgun
#9If anything, top level async would be an improvement, as it would give developers no reason to do synchronous IO.
Edit: Additionally, ES6 modules are already imperative. There isn't any way to make them declarative.