Created
July 12, 2015 10:38
-
-
Save denis-shvets/c4fd5326b6a8bd80e25d to your computer and use it in GitHub Desktop.
dom.ready
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
var domReady = function(callback) { | |
if(callback && typeof callback === 'function') { | |
if(!document.attachEvent || typeof document.attachEvent === 'undefined') { | |
document.addEventListener('DOMContentLoaded', function() { | |
return callback(); | |
}); | |
} else { | |
document.attachEvent('onreadystatechange', function() { | |
if(document.readyState === 'complete') { | |
return callback(); | |
} | |
}); | |
} | |
} else { | |
// Do something else | |
} | |
}; |
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
domReady(function() { | |
// | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment