1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Replace window.onload with window.addEventListener()

Since the `window` can only ever have one `onload` value, if ever a third-party script overwrites this property, the application risks never initializing.

By using `addEventListener('load',…)`, the application's bootstrapping logic is queued and is more likely to be initialized.
This commit is contained in:
Chauncey McAskill
2023-08-08 15:34:01 -04:00
parent 596ff7a8ee
commit 95caf9ebb5
4 changed files with 6 additions and 6 deletions

View File

@@ -1,3 +1,3 @@
{
"version": 1690813628192
"version": 1691523058315
}

View File

@@ -10,7 +10,7 @@ const app = new modular({
modules: modules,
});
window.onload = (event) => {
window.addEventListener('load', (event) => {
const $style = document.getElementById('main-css');
if ($style) {
@@ -24,7 +24,7 @@ window.onload = (event) => {
} else {
console.warn('The "main-css" stylesheet not found');
}
};
});
function init() {
globals();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long