Notice the standard HTML process
HTML
is parsed -- read & decoded
During parse JavaScript runs
allowing it to generate HTML,
e.g. document.write()
Browser
generates the page from HTML
After page generated all is quiet until an event happens,
caused by user or timer
Event
handlers handle the events, and then all is quiet again