Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dom-loaded

sindresorhus4.1kMIT3.1.0TypeScript support: included

Check when the DOM has loaded like DOMContentLoaded

browser, dom, document, ready, complete, check, wait, domcontentloaded, readystate

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.

domLoaded.signal

Type: AbortSignal

An AbortSignal that triggers when the DOM finishes loading or immediately if it has already loaded.