Change async stylesheet method, check stylesheet onload before init app

This commit is contained in:
Antoine Boulanger
2020-05-26 15:22:14 -04:00
parent a110cc7ae2
commit e910afc384
8 changed files with 25 additions and 16 deletions

View File

@@ -7,9 +7,23 @@ const app = new modular({
modules: modules
});
app.init(app);
globals();
window.onload = (event) => {
const $style = document.getElementById("stylesheet");
html.classList.add('is-loaded', 'is-ready');
html.classList.remove('is-loading');
if ($style.isLoaded) {
init();
} else {
$style.addEventListener('load', (event) => {
init();
});
}
};
function init() {
app.init(app);
globals();
html.classList.add('is-loaded', 'is-ready');
html.classList.remove('is-loading');
}