In a web page, when JavaScript starts to run?
Well, it depends on where javascript is written. It is executed as soon as it is downloaded (from a file) or as soon as it is read by browser if inline in html.
If your javascript is inside some event like window.onload or $(document).load(...) then it will be executed after page is rendered.
Event handlers are executed as a response to an event. So, there is no specific order here. As soon as the event occurs, event handler is fired.
Consider following example.
<html>
<body>
<h1 id="first">
First
</h1>
<script type="text/javascript" lazyload>
var first = document.getElementById('first'); // logs element
var second = document.getElementById('second'); //logs null
console.log(first);
console.log(second);
</script>
<h1 id="second">
Second
</h1>
<script type="text/javascript" lazyload>
var first = document.getElementById('first'); //logs element
var second = document.getElementById('second'); //logs element
console.log(first);
console.log(second);
</script>
</body>
</html>
Above example demonstrates that #first was rendered before js block 1 executed but #second was not rendered by this time.