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.
npm install @webfactoryde/document-ready
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();
});