1.0.1 • Published 8 years ago

@f/is-dom-loaded v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

is-dom-loaded

Build status Git tag NPM version Code style

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