async/defer attributes and DOM construction

2. script with defer

Result

Hello World!

Markup

<p id="result">
    Hello
    <script src="A.js" defer></script>
    <script src="B.js" defer></script>
    <script src="C.js" defer></script>
    World!
</p>

DOM elements and Events

Description

The browser that supports defer attribute will execute the script with defer after the document has finished parsing. This means that the scripts with defer does not block parsing when the parser meets them. In other words, the defer attribute is a declaration that there’s no document.write() inside of it and no DOM manipulation until the parser finish to analyze the page. Thus the parser can proceed to analyze the page safely.

And the order of execution between those scripts will be kept.