The event loop predates javascript.. but just by a tiny bit.
The event loop was introduced to support progressive download of pictures in Netscape. And almost immediately it was also used to support early rendering where DOM elements are displayed on screen before all images are downloaded.
At the time, other browsers displayed blank white screen while images are downloaded. The net effect is that Netscape appears to be faster even though it takes the same amount of time to download and render the complete page.
Once the event loop is there (initially to handle network code for downloading images) javascript processing was simply added into the loop.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…