0

I didn't find this anywhere, but what is the difference between the following two tags:

// Script tag w/out async and JUST the source attribute
<script src="script.js"></script>

// Script tag w/ async attribute (both ways of writing it shown)
<script src="script.js" async></script>
<script src="script.js" async="true"></script>

What's the difference between these two? How does it run in relation to the rest of an HTML page? And reading up about this from a page on DigitalOcian on async and defer has me more confused. I mean, defer sounds like the equivalent of <body onload="function()"> but for scripts (and when the page itself loads). Assuming my understanding is correct, async still confuses me.

  • 1
    This is more of a google where you'll get full, robust articles like https://javascript.info/script-async-defer – Kinglish Jul 16 '21 at 02:49
  • 1
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script – JLRishe Jul 16 '21 at 02:49
  • 1
    `async` means that the browser will go on processing the DOM and running other scripts without waiting until the script is fetched. It means that the scripts may not run in the order they're listed, which could have major implications if they have interdependencies. – JLRishe Jul 16 '21 at 02:51
  • 1
    @Kinglish That link is perfect, thank you! Not sure why I couldn't find it on my own, and I *was* trying to google it, too. I wish I found the site you linked to the first time around. – Anthony LoPrimo Jul 16 '21 at 03:18

0 Answers0