summaryrefslogtreecommitdiff
path: root/platform/javascript/js/engine/engine.js
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-12-21 14:41:26 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-02-06 18:46:22 +0100
commitcc4612277be252ca7b0b3b718a6142d4e01a6093 (patch)
treeca0061dc61b7eafa094d215b725a433db47b6455 /platform/javascript/js/engine/engine.js
parent95719930a8940d4737d512d75004e8b5cd50e825 (diff)
[HTML5] PWA service worker prefers cached version.
Use an offline first approach, where we prefer the cached version over the network one. This forces games using PWA to always re-export the project and not just the PCK, so that the service worker version gets updated correctly, and the end-user cache is correctly cleared on update.
Diffstat (limited to 'platform/javascript/js/engine/engine.js')
-rw-r--r--platform/javascript/js/engine/engine.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/platform/javascript/js/engine/engine.js b/platform/javascript/js/engine/engine.js
index 17a8df9e29..d2ba595083 100644
--- a/platform/javascript/js/engine/engine.js
+++ b/platform/javascript/js/engine/engine.js
@@ -189,6 +189,9 @@ const Engine = (function () {
preloader.preloadedFiles.length = 0; // Clear memory
me.rtenv['callMain'](me.config.args);
initPromise = null;
+ if (me.config.serviceWorker && 'serviceWorker' in navigator) {
+ navigator.serviceWorker.register(me.config.serviceWorker);
+ }
resolve();
});
});