By first line of Javascript I meant the JS code inside tags with no "src" attribute.
Asked
Active
Viewed 481 times
2 Answers
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.
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