-
-
Save dalethedeveloper/799285 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Works in Chrome, Firefox, MSIE, Opera and Safari. | |
*/ | |
function onDOMContentLoaded( event ) { | |
if( event ) { | |
document.removeEventListener( event.type, onDOMContentLoaded, false ); | |
} | |
document.onreadystatechange = null; | |
// For testing purposes. | |
alert( "DOM Content Loaded" ); | |
} | |
if( document.addEventListener ) { | |
document.addEventListener( "DOMContentLoaded", onDOMContentLoaded, false ); | |
} | |
document.onreadystatechange = function() { | |
if( document.readyState == "interactive" || document.readyState == "complete" ) { | |
onDOMContentLoaded( null ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hot sauce! Great snippet, man.