Files
OfficialSite/assets/scripts/app.js
Chauncey McAskill 0d42f65ff6 Skip init function if stylesheet not found
Instead of throwing an error about a member not being defined or accessed on NULL.
2021-04-09 15:23:45 -04:00

36 lines
732 B
JavaScript

import modular from 'modujs';
import * as modules from './modules';
import globals from './globals';
import { html } from './utils/environment';
const app = new modular({
modules: modules
});
window.onload = (event) => {
const $style = document.getElementById('main-css');
if ($style) {
if ($style.isLoaded) {
init();
} else {
$style.addEventListener('load', (event) => {
init();
});
}
} else {
console.warn('The "main-css" stylesheet not found');
}
};
function init() {
globals();
app.init(app);
html.classList.add('is-loaded');
html.classList.add('is-ready');
html.classList.remove('is-loading');
}