optimisation web pt 2

This commit is contained in:
2025-11-14 13:53:20 +02:00
parent b79decf04f
commit 121cde211f

View File

@@ -21,9 +21,10 @@
<!-- test stuff for speed --> <!-- test stuff for speed -->
<link rel="preconnect" href="https://cdnjs.cloudflare.com"> <link rel="preconnect" href="https://cdnjs.cloudflare.com">
<link rel="prefetch" href="flutter_bootstrap.js"> <link rel="preload" href="flutter_bootstrap.js" as="script">
<link rel="preload" href="main.dart.js" as="script">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<!-- Splash screen --> <!-- Splash screen -->
@@ -104,61 +105,6 @@
} }
</script> </script>
<style id="splash-screen-style"> <style id="splash-screen-style">
html { html {
height: 100% height: 100%
@@ -238,61 +184,6 @@
<img class="center" aria-hidden="true" src="splash/img/light-1x.gif" alt=""> <img class="center" aria-hidden="true" src="splash/img/light-1x.gif" alt="">
</picture> </picture>
<div id="seo-content" style="display:none;"> <div id="seo-content" style="display:none;">
<h1>Mzansi Innovation Hub (MIH) - Your All-in-One Super App for South Africa</h1> <h1>Mzansi Innovation Hub (MIH) - Your All-in-One Super App for South Africa</h1>
<p>Tired of juggling multiple apps? Mzansi Innovation Hub (MIH) presents the first super app designed specifically for the people and businesses of Mzansi. MIH is your unified online information technology system to streamline both your personal and professional life, bridging the socio-economic divide during the digital revolution.</p> <p>Tired of juggling multiple apps? Mzansi Innovation Hub (MIH) presents the first super app designed specifically for the people and businesses of Mzansi. MIH is your unified online information technology system to streamline both your personal and professional life, bridging the socio-economic divide during the digital revolution.</p>
@@ -327,31 +218,6 @@
// A more robust solution might involve listening for a Flutter-specific event when the app is ready. // A more robust solution might involve listening for a Flutter-specific event when the app is ready.
</script> </script>
<!-- Versioning -->
<!-- <script src="flutter.js" defer></script> -->
<!-- <script defer>
//var serviceWorkerVersion = '{{flutter_service_worker_version}}';
window.addEventListener('load', function (env) {
{{flutter_js}}
{{flutter_build_config}}
_flutter.loader.load({
serviceWorker: {
serviceWorkerVersion: {{flutter_service_worker_version}},
},
onEntrypointLoaded: function (engineInitializer) {
engineInitializer.initializeEngine().then(function (appRunner) {
appRunner.runApp();
});
}
});
});
</script> -->
<script> <script>
window.addEventListener("load", function (e) { window.addEventListener("load", function (e) {
document.addEventListener("focusin", function (event) { document.addEventListener("focusin", function (event) {
@@ -361,9 +227,11 @@
}); });
}); });
</script> </script>
<script defer=""> <script defer="">
    var serviceWorkerVersion = '{{flutter_service_worker_version}}';     var serviceWorkerVersion = '{{flutter_service_worker_version}}';
var scriptLoaded = false; var scriptLoaded = false;
var swFallbackTimeout;
function loadMainDartJs() { function loadMainDartJs() {
console.log('Loading app...'); console.log('Loading app...');
@@ -372,8 +240,8 @@
} }
scriptLoaded = true; scriptLoaded = true;
// Cancel Timeut // Cancel Timeut
if (window.swFallbackTimeout) { if (swFallbackTimeout) {
clearTimeout(window.swFallbackTimeout); clearTimeout(swFallbackTimeout);
console.log('Service worker loaded successfully - fallback timeout cancelled.'); console.log('Service worker loaded successfully - fallback timeout cancelled.');
} }
{{flutter_js}} {{flutter_js}}
@@ -388,6 +256,9 @@
}); });
} }
}); });
var finishLoad = new Date();
var loadTime = (finishLoad.getTime() - startLoad.getTime());
console.log("Load Time: " + loadTime);
} }
// Helper function to strip quotes from the version placeholder // Helper function to strip quotes from the version placeholder
@@ -404,12 +275,12 @@
navigator.serviceWorker.register(serviceWorkerUrl) navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => { .then((reg) => {
function waitForActivation(serviceWorker, isFirstTimeInstall) { function waitForActivation(serviceWorker, isFirstTimeInstall) {
serviceWorker.addEventListener('statechange', () => { serviceWorker.addEventListener('statechange', () => {
if (serviceWorker.state == 'activated') { if (serviceWorker.state == 'activated') {
console.log('Installed new service worker.'); console.log('Installed new service worker.');
loadMainDartJs(); loadMainDartJs();
// Only prompt if this is NOT the first time installing (i.e., returning user) // Only prompt if this is NOT the first time installing (i.e., returning user)
if (!isFirstTimeInstall && navigator.serviceWorker.controller) { if (!isFirstTimeInstall && navigator.serviceWorker.controller) {
console.log('New app version activated. Prompting for reload.'); console.log('New app version activated. Prompting for reload.');
@@ -454,17 +325,14 @@
// If service worker doesn't succeed in a reasonable amount of time, // If service worker doesn't succeed in a reasonable amount of time,
// fallback to plain <script> tag. // fallback to plain <script> tag.
setTimeout(() => { swFallbackTimeout = setTimeout(() => {
if (!scriptLoaded) { if (!scriptLoaded) {
console.warn( console.warn(
'Failed to load app from a service worker. Falling back to plain <script> tag.', 'Failed to load app from a service worker. Falling back to plain <script> tag.',
); );
loadMainDartJs(); loadMainDartJs();
} }
}, 4000); }, 1500);
var finishLoad = new Date();
var loadTime = (finishLoad.getTime() - startLoad.getTime());
console.log("Load Time: " + loadTime);
}); });
} }
else { else {