From 0d42f65ff6950785a29b028cdb6da6ac8922076e Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Fri, 9 Apr 2021 15:23:45 -0400 Subject: [PATCH] Skip init function if stylesheet not found Instead of throwing an error about a member not being defined or accessed on NULL. --- assets/scripts/app.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/assets/scripts/app.js b/assets/scripts/app.js index 94359d4..7aa6643 100644 --- a/assets/scripts/app.js +++ b/assets/scripts/app.js @@ -10,12 +10,16 @@ const app = new modular({ window.onload = (event) => { const $style = document.getElementById('main-css'); - if ($style.isLoaded) { - init(); - } else { - $style.addEventListener('load', (event) => { + if ($style) { + if ($style.isLoaded) { init(); - }); + } else { + $style.addEventListener('load', (event) => { + init(); + }); + } + } else { + console.warn('The "main-css" stylesheet not found'); } };