Reputation: 2290
ModuleA imports from ModuleB. And ModuleB imports from ModuleA. Both modules are loaded from the same folder into one .html
file.
What is the rule that determines which one gets executed first here?
The module below the other one (in source-order) actually seems to get executed first. This seems strange considering I recall reading somewhere that the order modules are executed in is (partly) determined by source-order.
<script type="module" src="../js/moduleB.js"></script>
<script type="module" src="../js/moduleA.js"></script>
Upvotes: 0
Views: 177
Reputation: 6058
Base on the information you are providing it makes sense that ModuleA is been executed first. Your second script tag importing ModuleA is actually redundant. Since you mentioned ModuleB imports ModuleA, ModuleA is executed first because all module imports are processed first. Assuming they are at the top of your script. This is more or less the order of execution.
../js/moduleB.js
is loaded.moduleB.js
are loaded and proceed. This includes ModuleA.Upvotes: 1