It says here that there are 4 ready states for html documents:
uninitialized - not yet started loading
upload - upload / download interactive - Loaded enough and the user can interact with it
full - fully loaded
It says here that basically deferral tells the browser to wait "until it's ready" before executing javascript in this script block. This is usually after the completion of the DOM loading and document.readyState == 4
So, the question is what is executed first and why - <script defer src = "..."> or window.onload = function () {...}?
user2022068
source share