Important note: if you create an extension with an Event Page ( "persistent": false in the manifest), setInterval with a 5-minute interval will fail because the background page will be unloaded.
If your extension uses window.setTimeout () or window.setInterval (), switch to using the crash API instead. DOM-based timers will not run if the event page turns off.
In this case, you need to implement it using the chrome.alarms API:
chrome.alarms.create("5min", { delayInMinutes: 5, periodInMinutes: 5 }); chrome.alarms.onAlarm.addListener(function(alarm) { if (alarm.name === "5min") { doStuff(); } });
In the case of constant background pages, setInterval is still an acceptable solution.
source share