Last active
September 7, 2017 16:52
-
-
Save Omar-Gonzalez/d70c8973fb148629c6508e5529a76b30 to your computer and use it in GitHub Desktop.
Custom Document Ready
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(t, n) { | |
function e() { | |
if (!a) { | |
a = !0; | |
for (var t = 0; t < d.length; t++) d[t].fn.call(window, d[t].ctx); | |
d = []; | |
} | |
} | |
function o() { | |
"complete" === document.readyState && e(); | |
} | |
t = t || "docReady"; | |
var d = [], a = !1, c = !1; | |
(n = n || window)[t] = function(t, n) { | |
if ("function" != typeof t) throw new TypeError("callback for docReady(fn) must be a function"); | |
a ? setTimeout(function() { | |
t(n); | |
}, 1) : (d.push({ | |
fn: t, | |
ctx: n | |
}), "complete" === document.readyState ? setTimeout(e, 1) : c || (document.addEventListener ? (document.addEventListener("DOMContentLoaded", e, !1), | |
window.addEventListener("load", e, !1)) : (document.attachEvent("onreadystatechange", o), | |
window.attachEvent("onload", e)), c = !0)); | |
}; | |
}("docReady", window); | |
docReady(function(){ | |
//do your stuff | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment