console.time('onload')
console.time('onreadystatechange')
window.onload = ()=>{console.log('onload'); console.timeEnd('onload')}
document.onreadystatechange = ()=>{console.log('onreadystatechange');console.log(document.readyState);console.timeEnd('onreadystatechange')}
I wrote the above code in an inline script, why the result is the following?
In theory, console.time('onreadystatechange')
should be executed first, but from the results, the onreadystatechange
event is executed first, and document.readyState
is 'complete', why is the event advanced?