I am developing a Chrome extension that tracks how long you have been using your computer. I increment using an interval, and am checking if the computer is locked using chrome.idle.queryState, and if it is locked I don't change my counter.
Is there a way to manually unload a background page, rather than constantly checking with an interval? Or does the background script ever unload and reload automatically, like after the computer is sleeping for X minutes? Since I have an interval, I wonder if the script will ever unload on its own. I do something similar to this:
setInterval(function () {
    chrome.idle.queryState(15, function (state) {
        if (state !== "locked") {
            counter += 1;
            console.log(counter);
        }
    }
}, 6000);
