Files
aboba/etc/hotreload.js
2025-06-20 14:35:12 +02:00

28 lines
487 B
JavaScript

let build_id = "";
async function fetch_until_ok(uri)
{
while (true) {
try {
return await fetch(uri);
} catch {
}
}
}
async function fetch_build_id()
{
const response = await fetch_until_ok("/build-id");
const json = await response.json();
return json.build_id;
}
setInterval(async function() {
let new_build_id = await fetch_build_id();
if (build_id !== new_build_id) {
location.reload(true);
}
}, 1000);