Reputation: 867
I'm looking at the example
https://github.com/webpack/webpack/tree/master/examples/multiple-commons-chunks
<html>
<head></head>
<body>
<script src="js/commons.js" charset="utf-8"></script>
<script src="js/admin-commons.js" charset="utf-8"></script>
<script src="js/adminPageA.js" charset="utf-8"></script>
</body>
</html>
Even though the js in the example is in the right sequence, but how do you know js/adminPageA.js
will not download and execute earlier than the js/common.js
, does webpack guarantee that, I'm actually quite confused if I need to have extra effort to make sure we load the script in right order ?? Or it is taken care by the webpack ??
I'm actually quite confused that with below sequence, my application code finish download before the common code, and it is yet still working ~ any explanation ??
Upvotes: 0
Views: 569
Reputation: 693
Your browser will wait for the first scripts it encounters to download and execute before executing any subsequent scripts, even if it went ahead and downloaded them in advance.
JQuery import is a classic example of this behavior, and you never have to worry about your subsequent scripts that use JQuery, as long as you import it first.
Upvotes: 1