If I include two scripts like so (one directly in the page, one in a remote resource):
<!-- ... -->
<script>
console.log('foo');
</script>
<script src="bar.js"></script>
<!-- ... -->
Is the order of evaluation guaranteed?
If I include two scripts like so (one directly in the page, one in a remote resource):
<!-- ... -->
<script>
console.log('foo');
</script>
<script src="bar.js"></script>
<!-- ... -->
Is the order of evaluation guaranteed?
Scripts are executed in the order they appear on the page. An exception is if an external Javascript has the async
attribute. This will be loaded in the background, and executed when the response arrives.