Trying to handle window.onreadystatechange, I notice this event firing two times during page load. But I cannot figure out what exactly becomes changed after each event. If it were not for window, but for document, then there had been document.readyState property containing the current state. But in case of window, there isn’t any “window.readyState” or similar property. So what does it really mean when a readystatechange event for window fires, and what the difference between the first and the second firing is?
Here is my code that gives two seemingly identical console outputs:
'use strict';
window.addEventListener('readystatechange', function(e) {
console.log(window, e);
});