How should the JS inside a <script async> be written? Does it really not use the DOM?

javascript dev.to

Hi, I understand the concept of in HTML:</p> <p>The script downloads asynchronously<br> It executes immediately once downloaded<br> It does not wait for the DOM to finish parsing</p> <p>But I’m confused about something. Some people say that JS loaded with async might be independent of the DOM.</p> <p>I want to know, how should the JS file actually be written? Is it really completely not supposed to use the DOM at all?</p> <p>I know the theory of async, but I don’t know what the JS file inside actually looks like. Could someone give an example of JS that works properly with <script async>?</p>

Source: dev.to

arrow_back Back to Tutorials