dom-loaded

Check when the DOM has loaded like `DOMContentLoaded`

Usage no npm install needed!

<script type="module">
  import domLoaded from 'https://cdn.skypack.dev/dom-loaded';
</script>

README

dom-loaded

Check when the DOM has loaded like DOMContentLoaded

Unlike DOMContentLoaded, this also works when included after the DOM was loaded.

Install

$ npm install dom-loaded

Usage

import domLoaded from 'dom-loaded';

await domLoaded;
console.log('The DOM is now loaded.');

API

domLoaded

Type: Promise<void>

The promise resolves when the DOM finishes loading or right away if the DOM has already loaded.

domLoaded.hasLoaded

Type: boolean

Synchronously check if the DOM has already finished loading.

Related