Using the "Task Scheduler" would be the best way to do this, then you really are not on a timeout or interval, but on a specific date
But this requires the use of service workers instead of ..., which is a chip. because then your site must also be whitelisted in order to start service workers (so that your site needs a valid SSL certificate)
// https://example.com/serviceworker.js this.ontask = function(task) { alert(task.data.message); console.log("Task scheduled at: " + new Date(task.time)); // From here on we can write the data to IndexedDB, send it to any open windows, // display a notification, etc. } // https://example.com/webapp.js function onTaskAdded(task) { console.log("Task successfully scheduled."); } function onError(error) { alert("Sorry, couldn't set the alarm: " + error); } navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { serviceWorkerRegistration.taskScheduler.add(Date.now() + (10 * 60000), { message: "It been 10 minutes, your soup is ready!" }).then(onTaskAdded, onError); });
source share