|
@@ -30,12 +30,11 @@ function run() {
|
|
|
}
|
|
|
|
|
|
if (canUseDOM) {
|
|
|
-// Run the application when both DOM is ready
|
|
|
-// and page content is loaded
|
|
|
- if (window.addEventListener) {
|
|
|
- window.addEventListener('DOMContentLoaded', run);
|
|
|
+ // Run the application when both DOM is ready and page content is loaded
|
|
|
+ if (['complete', 'loaded', 'interactive'].includes(document.readyState) && document.body) {
|
|
|
+ run();
|
|
|
} else {
|
|
|
- window.attachEvent('onload', run);
|
|
|
+ document.addEventListener('DOMContentLoaded', run, false);
|
|
|
}
|
|
|
}
|
|
|
|