Created
March 12, 2016 14:51
-
-
Save kapouer/7526c0c5d06afe41b0fc to your computer and use it in GitHub Desktop.
dom ready with IExx compat
This file contains 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
function waitReady(cb) { | |
if (waitReady.done) return cb(); | |
// https://github.com/jquery/jquery/issues/2100 | |
if (document.readyState == "complete" || | |
(document.readyState != "loading" && !document.documentElement.doScroll)) { | |
waitReady.done = true; | |
return setTimeout(cb); | |
} | |
var self = this; | |
function listener() { | |
document.removeEventListener('DOMContentLoaded', listener); | |
window.removeEventListener('load', listener); | |
if (waitReady.done) return; | |
waitReady.done = true; | |
cb(); | |
} | |
document.addEventListener('DOMContentLoaded', listener); | |
window.addEventListener('load', listener); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment