0

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?

Ben Aston
  • 53,718
  • 65
  • 205
  • 331

1 Answers1

1

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.

Barmar
  • 741,623
  • 53
  • 500
  • 612