1

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

Murali
  • 1,495
  • 2
  • 15
  • 28

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
  • 42,982
  • 15
  • 99
  • 131
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
  • 61,720
  • 15
  • 75
  • 100