I have the following test to see whether the defer
attribute defers execution of script block. There are 2 script blocks. 1st one with the defer
attribute and 2nd one with out. If I understand correctly, the attribute forces the browser to execute the block when all html parsing has been completed (including the other script
block).
But looking at the console, I always the 'from deferred' first. Why is that? Does defer
not work on the local script
blocks?
<html>
<body>
...
<script type="text/javascript" defer>
console.log('from deferred');
</script>
<script type="text/javascript">
console.log('from regular');
</script>
</body>
</html>