Javascript functions are invoked in only two ways in browsers:
They are explicitly invoked, within a
<script>
tag.They are invoked as the callback of an event handler
(or they are called by other functions, with the chain of function calls resulting from one of the two cases above)
In the former case, order of execution is controlled by the order of the <script>
tags, so the first function called will be the first function invocation (if any) found in those tags.
The only event that'll happen automatically as the page is loaded is the window.onload
event, so you can use that if you prefer instead of making an explicit function call.
In other words, order of execution is completely up to you.
There is no main
function.