is-dom-loaded
Check whether or not the document has finished loading
Installation
$ npm install @f/is-dom-loaded
Usage
var isDomLoaded = require('@f/is-dom-loaded')
var loaded = isDomLoaded()
var fns = []
if (!loaded) {
document.addEventListener('DOMContentLoaded', function listener () {
document.removeEventListener('DOMContentLoaded', listener)
fns.forEach(function (fn) {
fn()
})
})
}
function domready () {
loaded ? setTimeout(fn) : fns.push(fn)
}
API
isDomLoaded()
Returns: Boolean indicating whether or not the document has finished loading
License
MIT