I\'m writing a Javascript script. This script will probably be loaded asynchronously (AMD format).
In this script, I\'d like to do nothing important until the
Based on @CTS_AE's approach, I have put together a solution for envrionments where:
window.addEventListener('load', activateMyFunction); andwindow.addEventListener('DOMContentLoaded', activateMyFunction);don't work.
It requires a single character substitution (eg. from
window.addEventListener('load', activateMyFunction);
to
window_addEventListener('load', activateMyFunction);)
The function window_addEventListener() looks like this:
const window_addEventListener = (eventName, callback, useCapture = false) => {
if ((document.readyState === 'interactive') || (document.readyState === 'complete')) {
callback();
}
}