I have the following example:
<script >
console.log('first');
</script>
<script defer>
console.log('last');
</script>
<script>
console.log('second');
</script>
right in the head of my html, and I expect the console to print them in the asc order (first-second-third), however, what I actually see follows the order in which those scripts where placed (first - last - second).
I thought the 'defer' attribute will load the script, but will execute is until the DOM has been completely loaded. Dunno why this is not happening.
Regards,
deferis only for external scripts, not inline code, which doesn't need to load...