@f/is-dom-loaded

Check whether or not the document has finished loading

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/is-dom-loaded
001.0.16 years ago6 years agoMinified + gzip package size for @f/is-dom-loaded in KB

Readme

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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.