@webfactoryde/document-ready
v1.0.0
Published
JS Utility to init asynchonously loaded scripts when the DOM is ready
Keywords
Readme
documentReady Utility
The documentReady utility is a simple JavaScript function that allows you to execute a callback function once the HTML document has fully loaded. This is particularly useful for ensuring that asynchronously loaded scripts run only after the DOM is ready, preventing potential issues with elements not being available when your code executes.
Installation
npm install @webfactoryde/document-readyUsage
Import the documentReady function in your module(s) and pass a callback:
// your module
import documentReady from '@webfactoryde/document-ready';
function init() {
// do stuff
}
documentReady(function() {
init();
});