@f/is-dom-loaded

    1.0.1 • Public • Published

    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

    Keywords

    none

    Install

    npm i @f/is-dom-loaded

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • f