Skip to content

Latest commit

 

History

History
67 lines (56 loc) · 2.33 KB

README.md

File metadata and controls

67 lines (56 loc) · 2.33 KB

A experiment about script loading

Something about the experiment

When I was preparing for the interview this autumn. I was always asked that

"Do you know the two properties of defer and async on the <script>? What are the functions of these two properties ?"

Of course! There are so many answers on the forum, and it is easy to get the answer. But is it true? And that's why I start this experiment.
In this experiment, I resort to the Performance in Chrome Devtool. Let's begin!

Normal

<body>
    <h1>Script without defer or async</h1>
    <script src="./src/normal.js"></script>
</body>

some screenshots

please config your DNS


please config your DNS


please config your DNS


please config your DNS

picture from forum

please config your DNS

Defer

<body>
    <h1>Script with defer</h1>
    <script defer src="./src/defer.js"></script>
</body>

some screenshots

please config your DNS
Between finishing parsing html and executing javascript code, there isn't layout,paint or composite.


please config your DNS


please config your DNS

picture from forum

please config your DNS

Async

<body>
    <h1>Script with async</h1>
    <script async src="./src/async.js"></script>
</body>

some screenshots

please config your DNS


please config your DNS


please config your DNS

picture from forum

please config your DNS


please config your DNS