# wicg/page-lifecycle architecture

> Architecture diagram of the GitHub repository wicg/page-lifecycle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wicg/page-lifecycle
- Repository: https://github.com/wicg/page-lifecycle

## Overview

This repository proposes a web-page lifecycle API, not a runtime application. Its central workflow is that browser or system lifecycle transitions notify a page through freeze/resume callbacks, letting the application release or restore resources; a discarded page can detect that state on reload. The README also documents BFCache callback ordering and system interventions for CPU and memory. No source excerpts were provided, so relationships below rely on README statements; spec.bs is the specification source identified by the repository tree.

Main entry points: [`spec.bs`](https://github.com/wicg/page-lifecycle/blob/main/spec.bs) (Frame lifecycle states)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Lifecycle model"]
  node_states["Frame lifecycle states<br/>[spec.bs]"]
  node_end_scenarios["End-of-life scenarios<br/>[spec.bs]"]
end

subgraph group_api["Page API"]
  node_document_api["Document API<br/>[spec.bs]"]
  node_freeze_resume["Freeze/resume events<br/>[spec.bs]"]
  node_discard_restore["Discard restoration<br/>[spec.bs]"]
  node_bfcache["BFCache integration<br/>[spec.bs]"]
end

subgraph group_interventions["System interventions"]
  node_cpu_stop["CPU suspension<br/>[spec.bs]"]
  node_tab_discard["Tab discarding<br/>[spec.bs]"]
end

node_browser(("Browser"))
node_system(("Operating system"))
node_app(("Web application"))

node_browser -->|"transitions frames"| node_states
node_system -->|"stops CPU"| node_cpu_stop
node_system -->|"reclaims memory"| node_tab_discard
node_cpu_stop -->|"moves to frozen"| node_states
node_tab_discard -->|"moves to discarded"| node_states
node_states -->|"signals transitions"| node_freeze_resume
node_freeze_resume -->|"exposes handlers"| node_document_api
node_app -->|"handles callbacks"| node_document_api
node_states -->|"sets wasDiscarded"| node_discard_restore
node_discard_restore -->|"supports restoration"| node_app
node_bfcache -->|"orders callbacks"| node_freeze_resume
node_browser -->|"enters or exits"| node_bfcache
node_states -->|"covers termination"| node_end_scenarios

click node_states "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_end_scenarios "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_document_api "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_freeze_resume "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_discard_restore "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_bfcache "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_cpu_stop "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"
click node_tab_discard "https://github.com/wicg/page-lifecycle/blob/main/spec.bs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_states,node_end_scenarios,node_browser toneBlue
class node_document_api,node_freeze_resume,node_discard_restore,node_bfcache toneAmber
class node_cpu_stop,node_tab_discard toneMint
class node_system,node_app toneIndigo
```

## Components

### Lifecycle model

- [Frame lifecycle states](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`
- [End-of-life scenarios](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`

### Page API

- [Document API](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`
- [Freeze/resume events](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`
- [Discard restoration](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`
- [BFCache integration](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`

### System interventions

- [CPU suspension](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`
- [Tab discarding](https://github.com/wicg/page-lifecycle/blob/main/spec.bs): `spec.bs`

### Other components

- **Browser**
- **Operating system**
- **Web application**

## Connections

- Browser → Frame lifecycle states: transitions frames (evidence: `README.md`)
- Operating system → CPU suspension: stops CPU (evidence: `README.md`)
- Operating system → Tab discarding: reclaims memory (evidence: `README.md`)
- CPU suspension → Frame lifecycle states: moves to frozen (evidence: `README.md`)
- Tab discarding → Frame lifecycle states: moves to discarded (evidence: `README.md`)
- Frame lifecycle states → Freeze/resume events: signals transitions (evidence: `README.md`)
- Freeze/resume events → Document API: exposes handlers (evidence: `README.md`)
- Web application → Document API: handles callbacks (evidence: `README.md`)
- Frame lifecycle states → Discard restoration: sets wasDiscarded (evidence: `README.md`)
- Discard restoration → Web application: supports restoration (evidence: `README.md`)
- BFCache integration → Freeze/resume events: orders callbacks (evidence: `README.md`)
- Browser → BFCache integration: enters or exits (evidence: `README.md`)
- Frame lifecycle states → End-of-life scenarios: covers termination (evidence: `README.md`)
