# Badge updates do not trigger excessive background CPU usage

- **Pattern:** `ab-001369` (`extension-ux-performance.badge-notifications.badge-cpu-usage`)
- **Severity:** medium
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001369
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001369)

## Why it matters

Badge update calls fired on every high-frequency browser event — `webRequest.onCompleted`, `tabs.onUpdated`, or sub-5-second polling — create continuous background CPU load even when the user is doing nothing extension-related. ISO 25010:2011 performance-efficiency.resource-utilisation treats unnecessary background CPU consumption as a defect. On laptops, this translates directly to battery drain; on lower-end hardware it causes system-wide slowdown. Chrome surfaces extensions that abuse background resources in its Task Manager, leading to removal.

## Severity rationale

Medium because unbounded badge update frequency drains battery and CPU continuously, but the impact is gradual and not immediately catastrophic.

## Remediation

Debounce badge updates so high-frequency trigger events coalesce into at most one update per 500ms, and skip the `setBadgeText` call entirely when the value has not changed.

```js
let currentBadgeText = '';
let badgeUpdateTimer = null;

function scheduleBadgeUpdate() {
  clearTimeout(badgeUpdateTimer);
  badgeUpdateTimer = setTimeout(async () => {
    const count = await computeCount();
    const newText = count > 0 ? String(count) : '';
    if (newText !== currentBadgeText) {
      currentBadgeText = newText;
      chrome.action.setBadgeText({ text: newText });
    }
  }, 500);
}
```

For polling patterns, use `chrome.alarms` with a minimum 30-second interval and add idle detection via `chrome.idle` to pause updates when the system is idle.

## Detection

**The detection method for this pattern is part of AuditBuffet Pro.**

The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the [Extension UX & Performance Audit](https://auditbuffet.com/audits/extension-ux-performance). The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.

## External references

- iso-25010 performance-efficiency.resource-utilization

Taxons: performance, cost-efficiency

HTML version: https://auditbuffet.com/patterns/ab-001369
