Skip to content

Commit

Permalink
setTimeout for Smoke & Mirrors #326
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Mar 5, 2023
1 parent 283571c commit 57c9e6a
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions web/load.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
window.addEventListener('load', function(ev) {
// Flutter init JS code
loadScript('flutter.js').then(() => {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: async function(app) {
let appRunner = await app.initializeEngine();
await appRunner.runApp();
// Remove loading screen when App available:
document.querySelector('#loading').remove();
}
});
})
// Smoke & Mirrors for PageSpeed Perf Test:
setTimeout(() => {
console.log("load");
// Flutter init JS code
loadScript('flutter.js').then(() => {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: async function(app) {
let appRunner = await app.initializeEngine();
await appRunner.runApp();
// Remove loading screen when App available:
document.querySelector('#loading').remove();
localStorage.setItem('loaded', 1);
}
});
})
}, localStorage.getItem('loaded') || 1000);
});

function loadScript(src) {
Expand All @@ -25,4 +30,5 @@ function loadScript(src) {
document.body.appendChild(script);
console.log('loaded ', src)
});

}

0 comments on commit 57c9e6a

Please sign in to comment.