Last active
March 11, 2023 16:27
-
-
Save jasonhofer/dd63635c16a4060abad3 to your computer and use it in GitHub Desktop.
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
const init = new function () { | |
let funcs = [], | |
booted = 0, | |
doc = document, | |
ready = fn => { | |
'loading' === doc.readyState ? | |
doc.addEventListener('DOMContentLoaded', fn) : | |
fn(); | |
}; | |
this.push = fn => { | |
booted ? ready(fn) : funcs.push(fn); | |
}; | |
this.boot = () => { | |
if (!booted) { | |
booted = 1; | |
funcs.forEach(fn => ready(fn)); | |
} | |
}; | |
}; | |
/* minified */ | |
const init=new function(f=[],b=0,d=document,r=c=>"loading"===d.readyState?d.addEventListener("DOMContentLoaded",c):c()){this.push=c=>{b?r(c):f.push(c)};this.boot=_=>{if(!b){b=1;f.forEach(c=>r(c))}}}; | |
/* jQuery version */ | |
const init=new function(f=[],b=0){this.push=c=>{b?$(c):f.push(c)};this.boot=_=>{if(!b){b=1;f.forEach(c=>$(c))}}}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment