1

By first line of Javascript I meant the JS code inside tags with no "src" attribute.

Murali
  • 1,455
  • 2
  • 12
  • 27

2 Answers2

1

By right it will be evaluated top down.

Read more about it from my previous answer: Load and execution sequence of a web page?

Let me explain here:

<script type="text/javascript">
  alert(jQuery); // alerts jQuery's namespace
</script>
<script type="text/javascript" src="jquery.js"></script>

The result is alerting undefined.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  alert(jQuery); // alerts jQuery's namespace
</script>

The result is alerting a object/function where defined.

Community
  • 1
  • 1
mauris
  • 41,504
  • 15
  • 94
  • 130
1

The scripts are executed in the order they are listed in the html. It does not matter if they are inline JavaScript (within <script> tags) or if loaded as external scripts (<script src="xx.js">).

TheHippo
  • 58,689
  • 15
  • 73
  • 98