You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a suggestion. In a regular PWA - I am writing this code in the HTML-HEAD Script tag. Mainly to avoid loading the bundle again after the PWA is install (reducing server load).
I am just checking display-mode: standalone, may be a better method exists. So the entire script is available only if the APP is not installed. Anyway great work on automating the INSTALL process in a much nicer way. Anyway tried it on the demo and its working as expected.
@khmyznikov - your comments much appreciated. (Especially on the method and its usage - any downside ?)
<script>
if(window.matchMedia('(display-mode: standalone)').matches) {
console.log("INSTALL JS Not required - not loaded");
// do not do it
} else {
console.log("Loading JS")
let scriptEle = document.createElement("script");
scriptEle.setAttribute("src", "./pwa-install.bundle.js");
scriptEle.setAttribute("type", "module");
document.head.appendChild(scriptEle);
scriptEle.addEventListener("load", () => {
console.log("Installer Script File loaded")
});
scriptEle.addEventListener("error", (ev) => {
console.log("Error : Installer Script File Not Loaded", ev);
});
}
</script>
The text was updated successfully, but these errors were encountered:
Yeah I think your approach should work. I can only suggest to try to play with: <script type="module"> import "./pwa-install.bundle.js"; </script> https://www.w3schools.com/js/js_modules.asp
Hi @khmyznikov
Just a suggestion. In a regular PWA - I am writing this code in the HTML-HEAD Script tag. Mainly to avoid loading the bundle again after the PWA is install (reducing server load).
I am just checking display-mode: standalone, may be a better method exists. So the entire script is available only if the APP is not installed. Anyway great work on automating the INSTALL process in a much nicer way. Anyway tried it on the demo and its working as expected.
@khmyznikov - your comments much appreciated. (Especially on the method and its usage - any downside ?)
The text was updated successfully, but these errors were encountered: