From 57ef45d288fae81000e1d8669c0ddd68aa27cb63 Mon Sep 17 00:00:00 2001 From: altaf-creator <64111012+altaf-creator@users.noreply.github.com> Date: Thu, 4 May 2023 20:27:00 +0700 Subject: PWA Update - attempt 4.1 | it doesn't work :( --- src/scripts/main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/scripts/main.js') diff --git a/src/scripts/main.js b/src/scripts/main.js index e4efee0..091a3d2 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,5 +1,17 @@ +function urlExists(url) { + var http = new XMLHttpRequest(); + http.open('HEAD', url, false); + if (http.status != 200) + console.log(`${http.status} ${url} `) + http.send(); + return http.status != 404; +} + if ("serviceWorker" in navigator) { window.addEventListener("load", function () { + for (var i = 0; i < assets.length; i++) { + urlExists(assets[i]); + } navigator.serviceWorker .register("scripts/service-worker.js") -- cgit v1.2.3