4 ms·
That's false. Module loading and execution are separate stages. The dependent modules would load before this await is ever reached.
by domenicd 10y ago
That's false. Module loading and execution are separate stages. The dependent modules would load before this await is ever reached.
- gavinpc 10y agoWait... so the OP's premise is completely wrong? Doesn't the body of a module have to complete before dependent modules will execute their bodies? In other words, if you put for (let i = 0; i < 10e8; i++) // blah in the body of a module, wouldn't that block dependent modules for the duration of the loop? Would top-level await be different? edit The premise, as I understand it, is that the module itself is treated as the "currently-executing method" for the purpose of the `await`.
- domenicd 10y agoIt would block dependent module execution, but not dependent module fetching, which is the actual expensive part.
- s_kilk 10y agoIt's kinda funny how the semantics of this thing are so non-obvious and nuanced, that it takes so much effort to explain to people how it works :)
- domenicd 10y agoIt's not that complicated; unfortunately a lot of FUD has been spread about alternate models based on misconceptions, which definitely makes it tricky to explain because you have to overcome that FUD.
- nolanl 10y agoSounds like I misunderstood. Thanks for the correction!