This commit is contained in:
2024-09-18 14:59:26 +02:00
parent e85833499c
commit 738e31bc71

View File

@@ -121,7 +121,7 @@
<!-- Versioning --> <!-- Versioning -->
<!-- <script src="flutter_bootstrap.js?v0.0.0.40" async></script> --> <!-- <script src="flutter_bootstrap.js?v0.0.0.40" async></script> -->
<script defer> <script defer>
var startLoad = new Date();
var serviceWorkerVersion = '{{flutter_service_worker_version}}'; var serviceWorkerVersion = '{{flutter_service_worker_version}}';
var scriptLoaded = false; var scriptLoaded = false;
function loadMainDartJs() { function loadMainDartJs() {
@@ -139,6 +139,7 @@
} }
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
var startLoad = new Date();
// Service workers are supported. Use them. // Service workers are supported. Use them.
window.addEventListener('load', function () { window.addEventListener('load', function () {
// Wait for registration to finish before dropping the <script> tag. // Wait for registration to finish before dropping the <script> tag.
@@ -182,22 +183,16 @@
} }
}); });
}); });
var finishLoad = new Date();
if (navigator.serviceWorker.state == 'activated') { var loadTime = (finishLoad.getTime() - startLoad.getTime());
console.log('Latest Service Worker Installed.'); console.log("Load Time: " + loadTime);
loadMainDartJs();
// if there's an existing controller (previous Service Worker), show the prompt
// you can tweak this and delay the notification once the page is load you can show a notification and ask for a new refresh
}
} }
else { else {
// Service workers not supported. Just drop the <script> tag. // Service workers not supported. Just drop the <script> tag.
console.log('Service Not Supported.'); console.log('Service Not Supported.');
loadMainDartJs(); loadMainDartJs();
} }
var finishLoad = new Date();
var loadTime = (finishLoad.getTime() - startLoad.getTime());
console.log("Load Time: " + loadTime);
</script> </script>
<!-- <script defer> <!-- <script defer>
var serviceWorkerVersion = '{{flutter_service_worker_version}}'; var serviceWorkerVersion = '{{flutter_service_worker_version}}';