Detect when an element is ready in the DOM
$ npm install element-ready
const elementReady = require('element-ready');
(async () => {
const element = await elementReady('#unicorn');
console.log(element.id);
//=> 'unicorn'
})();
Returns a promise for a matching element.
Type: string
Type: Object
Type: Element
document
Default: document
The element that's expected to contain a match.
Type: Function
Stops checking for the element to be ready. The cancelation is synchronous.
Calling it after the promise has settled or multiple times does nothing.
Based on p-cancelable.
- dom-loaded - Check when the DOM is loaded like
DOMContentLoaded
MIT © Sindre Sorhus