JavaScript Ninja - So You Want document.readyState Changes To Be An Event ? Sure You Do! MutationObserver To The Rescue

Posted at

why using just one bug'gy method of onreadystatechange when you can use the newly MutationObserver ;)

var mutation_observer = new MutationObserver(function(){
  console.log(arguments)
});


mutation_observer.observe(document, {
  attributeFilter:        ["readyState"]
, attributeOldValue:      true
, attributes:             true
, characterData:          false
, characterDataOldValue:  false
, childList:              false
, subtree:                false
});


:)