As the picture shows, i have a html which contain tree script tags and one css link, two of the scripts are loaded by asynchronous methods. From what I have learned, The browser loads in the order in which the script appears in html. But when I open the chrome devtool to analyze the detail. I found that the loading of the second script wa blocked by css resources.
<head>
<title>css-block-js-parse</title>
<!-- I have a express server to mock delay of resources, the query param `sleep` is the
delay time -->
<link rel="stylesheet" href="./static/style.css?sleep=1500">
<script src="./static/index1.js?sleep=2400" async></script>
<script src="./static/index2.js?sleep=1000" async></script>
<script src="./static/index3.js?sleep=1000"></script>
</head>
<body>
<p>hello world</p>
</body>
The screenshot below is what i found in the tool. click for my image
I have the following understanding:
- why asynchronously script index2.js are slower than non-asynchronous script index3.js, and not in the order they appear in the html?
- why the first asynchronously script index1.js unaffected by css loading?
Thanks in advance!