Skip to main content
Zimt

Home baking recipes and cinnamon favourites

Why Cookie Clicker Doesn't Run in the Background

Cookie Clicker pauses when you switch to another tab or minimize the browser because modern browsers deliberately throttle or suspend JavaScript execution in background pages.

Cookie Clicker is a browser‑based incremental game written in JavaScript. The core loop runs on a setInterval or requestAnimationFrame callback that updates the cookie count several times per second, applies upgrades, and redraws the UI. Each tick also writes the current state to localStorage so the game can be resumed after a page reload. Because the game relies on continuous execution of these timers, any interruption in the JavaScript engine directly affects the visible cookie count.

The game also includes an “offline progress” mechanic. When you close the tab or lose focus, the script records the timestamp of the last tick. Upon returning, it calculates the elapsed time and adds the appropriate number of cookies as if the game had kept running. This design choice reduces the need for a truly background‑running process, but it also means the developer does not try to keep the script alive when the browser decides otherwise.

How the Game Uses Timers

Cookie Clicker’s main timer is typically set to fire every 100 ms (10 times per second). Inside that callback the game checks the current “cookies per second” (CPS) value, increments the total, and updates the visual display. The same timer also checks for achievements, auto‑clickers, and other time‑based events. Because these operations are lightweight, they can run many times per second without noticeable CPU load when the tab is active.

When the tab becomes inactive, browsers treat the page as low priority. In Chrome, for example, background tabs have their timers clamped to a minimum interval of 1000 ms, and in some cases they are completely paused after a few minutes. Firefox and Edge apply similar limits. The result is that the setInterval callback fires far less often, making the visible cookie count appear frozen.

Browser Tab Throttling Explained

All major browsers implement a policy called “timer throttling” to conserve CPU, battery, and memory. The policy works by monitoring the visibility state of each page via the Page Visibility API. When document.hidden becomes true, the browser reduces the frequency of timer callbacks, sometimes to one per second, and may even stop timers altogether if the tab remains hidden for an extended period.

This behavior is intentional: background tabs rarely need high‑frequency updates, and unrestricted timers would waste resources on pages the user is not actively watching. The policy also mitigates abusive scripts that try to mine cryptocurrency or perform denial‑of‑service attacks from hidden tabs.

Game Design Intent

The creator of Cookie Clicker, Orteil, designed the game with the expectation that browsers would throttle background execution. Instead of trying to keep the script alive, the game records the last active timestamp and calculates offline earnings on return. This approach respects user resources and aligns with the incremental genre’s philosophy that progress can be earned even while you are away, without needing the game to run continuously.

Additionally, keeping the game active in the background could give players an unfair advantage in competitive leaderboards. By standardising offline calculation, every player receives the same amount of cookies for a given period of inactivity, regardless of their device’s power settings.

Common Workarounds and Their Limits

  • Use a dedicated browser window and keep it in the foreground. This prevents throttling but consumes more screen space.
  • Enable “background tab” extensions that attempt to override the browser’s timer limits. Most modern browsers block such extensions for security reasons, and they often cause instability.
  • Run the game in a desktop application wrapper like Electron. This bypasses the browser’s visibility checks, but it requires downloading a separate executable and may still be subject to OS‑level power‑saving features.
  • Rely on the built‑in offline calculation. This is the safest and most reliable method; the game will credit you the correct amount of cookies based on the elapsed time.

It is worth noting that none of these workarounds change the underlying game code; they merely affect how the browser treats the page. Because Cookie Clicker does not use Web Workers or Service Workers to perform background computation, there is no native way for the game to stay active while hidden.

Safety, Performance, and Battery Considerations

Allowing a JavaScript‑heavy page to run at full speed in the background can drain laptop batteries and increase CPU temperature. Users who leave Cookie Clicker open on a laptop overnight may notice reduced battery life, especially on older hardware. The browser’s throttling helps avoid that by scaling back work when the page is not visible.

From a security perspective, the game does not request any special permissions, and it stores data only in the browser’s local storage. There is no risk of malware or data leakage from the background‑run behaviour itself. However, users should still keep their browsers up to date to benefit from the latest throttling and sandboxing improvements.

Frequently Asked Questions

Does Cookie Clicker ever run when the tab is hidden?

Only the minimal offline‑progress calculation runs. The visual timer and UI updates are paused, but when you return the game adds cookies based on the time that passed.

Can I force the game to keep ticking in the background?

Not reliably. Some browsers allow experimental flags to disable throttling, but those settings affect all tabs and can cause performance issues. Using a dedicated app wrapper is the only practical way to keep the script active.

Why does the game still give me cookies after I’ve been away?

When you leave, the game stores the current timestamp. On return it computes the difference, multiplies by your CPS, and credits the result. This offline mechanic is built into the game’s code.

Will disabling background throttling give me an advantage in leaderboards?

No. Leaderboards calculate total cookies based on the stored timestamp, not on how many ticks actually ran while you were away. Any extra ticks are ignored in the final count.

Is there a mobile‑specific reason the game stops?

Mobile browsers often suspend JavaScript entirely when the app is not in the foreground to preserve battery. The same offline‑calculation logic applies when you reopen the page.

Does using an ad‑blocker affect background execution?

Ad‑blockers do not influence timer throttling. They may prevent external scripts from loading, but the core game loop remains subject to the browser’s visibility rules.

Read next