function ready(callback) {
  let onLoaded = (event) => {
    if (document.addEventListener) {
      document.removeEventListener('DOMContentLoaded', onLoaded, false);
      window.removeEventListener('load', onLoaded, false);
    }
    else if (document.attachEvent) {
      document.detachEvent('onreadystatechange', onLoaded);
      window.detachEvent('onload', onLoaded);
    }

    setTimeout(callback, 1);
  };

  if (document.readyState === 'complete') return setTimeout(callback, 1);

  if (document.addEventListener) {
    document.addEventListener('DOMContentLoaded', onLoaded, false);
    window.addEventListener('load', onLoaded, false);
  }
  else if (document.attachEvent) {
    document.attachEvent('onreadystatechange', onLoaded);
    window.attachEvent('onload', onLoaded);
  }
}
/**
 * Helper function for invoking a callback when the DOM is ready.
 *
 * @param {Function} callback
 *
 * @private
 */
Helper function for invoking a callback when the DOM is ready.
@param {Function} callback

@private
Helper function for invoking a callback when the DOM is ready . @param { Function } callback @private
function ready(callback) {
  let onLoaded = (event) => {
    if (document.addEventListener) {
      document.removeEventListener('DOMContentLoaded', onLoaded, false);
      window.removeEventListener('load', onLoaded, false);
    }
    else if (document.attachEvent) {
      document.detachEvent('onreadystatechange', onLoaded);
      window.detachEvent('onload', onLoaded);
    }
    setTimeout(callback, 1);
  };
  if (document.readyState === 'complete') return setTimeout(callback, 1);
  if (document.addEventListener) {
    document.addEventListener('DOMContentLoaded', onLoaded, false);
    window.addEventListener('load', onLoaded, false);
  }
  else if (document.attachEvent) {
    document.attachEvent('onreadystatechange', onLoaded);
    window.attachEvent('onload', onLoaded);
  }
}
function ready ( callback ) { let onLoaded = ( event ) => { if ( document . addEventListener ) { document . removeEventListener ( 'DOMContentLoaded' , onLoaded , false ) ; window . removeEventListener ( 'load' , onLoaded , false ) ; } else if ( document . attachEvent ) { document . detachEvent ( 'onreadystatechange' , onLoaded ) ; window . detachEvent ( 'onload' , onLoaded ) ; } setTimeout ( callback , 1 ) ; } ; if ( document . readyState === 'complete' ) return setTimeout ( callback , 1 ) ; if ( document . addEventListener ) { document . addEventListener ( 'DOMContentLoaded' , onLoaded , false ) ; window . addEventListener ( 'load' , onLoaded , false ) ; } else if ( document . attachEvent ) { document . attachEvent ( 'onreadystatechange' , onLoaded ) ; window . attachEvent ( 'onload' , onLoaded ) ; } }
Helper function for invoking a callback when the DOM is ready.
Helper function for invoking a callback when the DOM is ready .