diff --git a/static/js/live-reload.js b/static/js/live-reload.js index b43b973..5b69db9 100644 --- a/static/js/live-reload.js +++ b/static/js/live-reload.js @@ -1,8 +1,14 @@ // NOTE: The server never fulfills this request, it stalls forever. // Once the connection is closed, we try to connect with the server until we establish a successful // connection. Then we reload the page. + +let shouldReload = true; +addEventListener("beforeunload", () => { + shouldReload = false; +}); + await fetch("/dev/live-reload/stall").catch(async () => { - while (true) { + while (shouldReload) { try { let response = await fetch("/dev/live-reload/back-up"); if (response.status == 200) {