> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usedynamite.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Read /start/capabilities before choosing an integration. Use the deployed server’s tools/list for current tool inputs.

# Script lifecycle

> Initialization, requests, timing, and caching.

## Initialization sequence

1. Read `document.currentScript`, resolve the workspace runtime base and install `window.dynamite`.
2. Drain queued commands. `track` calls may wait for a visitor runtime; the queue is bounded at 50 pending track commands.
3. Wait for `DOMContentLoaded` if necessary.
4. Skip live initialization if an extension preview is taking ownership, a visitor runtime already exists, consent is denied, or required consent is absent.
5. Request `GET /site?features=editorial-v3&path=…`, with omitted credentials and a 1,800 ms fetch timeout.
6. Require the response's origin to equal `location.origin` and its mode to be `live`.
7. Install visitor storage, activity observers, target adapters, navigation hooks, measurement and optional enrichment.
8. Flush queued tracking and report the installation path and revision to `/installed`.

A failed request leaves the base website intact. A 403 configuration response can still produce an installation check-in, allowing installation to be recognized before the first live release. A check-in is evidence the script ran, not evidence that a variant was applied.

## Requests you will see

| Request | Purpose | Timing |
| - | - | - |
| `GET /dynamite.js` | Load shared code | Document load |
| `GET /personalization/runtime/:workspace/site` | Published configuration and public settings | Initialization; editorial page resolution as needed |
| `POST …/installed` | Installation receipt | Initialization |
| `POST …/decide` | Bounded profile → approved choices | Eligible registered pages |
| `POST …/collect` | Batched measurement | During the visit and on leave |
| `POST …/enrich` | Request connected context | Separately, when enabled and needed |

The installer uses JSON bodies with a CORS-safelisted `text/plain;charset=UTF-8` content type for public posts. Requests omit cookies/credentials to Dynamite. The runtime validates the site's exact origin; a copied snippet on another origin does not grant access.

## Page lifecycle and stability

On a registered path, the runtime binds only targets whose selector resolves to one element. It records the registered page/product view, determines experiment membership, checks eligibility, and requests a decision when there is a choice to make.

The current automatic browser budget is **1,800 ms from navigation start**, including time before the decision request. Loading the script late can consume that budget. For SPA navigations the clock starts at the route change. The normal server decision budget is **1,500 ms**. These are cutoffs, not expected latency.

Live automatic changes stop when the visitor has already interacted on that path. A receipt arriving after navigation, a visitor reset, the deadline, or an interaction is not applied. Native ordering and editorial placements have additional visibility/focus guards.

Behavior normally informs the next navigation or an explicit internal refresh. A new click is not an instruction to repeatedly repaint the current page. Connected enrichment completion updates context but does not automatically rerun the current decision.

## Navigation and teardown

The runtime observes `pushState`, `replaceState`, `popstate`, back/forward cache restoration and path changes. It schedules route binding on the next animation frame; a 250 ms path check supports isolated extension contexts. Matching uses `location.pathname`, not a generic URL rule engine. Ordinary pages must be explicitly registered; editorial templates have their own resolver.

On navigation, old requests are canceled and old bindings restored/destroyed. On teardown, listeners, observers, styles and tracking are removed and original content restored. There is no general mutation-observer adapter that waits indefinitely for arbitrary framework hydration.

## Caching and updates

| Layer | Current behavior |
| - | - |
| CDN installer | 300 seconds browser cache, 60 seconds stale-while-revalidate in the CDN build |
| App-served installer | 300 seconds browser cache, 86,400 seconds stale-while-revalidate, ETag |
| Live `/site` | 20 seconds public cache, varies by origin |
| Server live-record cache | 10 seconds; invalidated by relevant writes |
| Decision / private preview | No-store |

An already-open page retains its installed runtime and configuration. Publishing, pausing or rolling back is not a push update to every open tab. Reload/navigate and verify the returned revision. Keep APIs compatible with cached scripts.

## Content Security Policy

Permit the actual script origin in your site's `script-src`, the API origin in `connect-src`, and approved image origins in `img-src`. Component styling includes injected/inline CSS; check your existing `style-src` policy against the runtime. Do not weaken a restrictive policy without review; this build has no general merchant nonce configuration. Use the browser console and Network panel to identify blocked resources.

Source: [installer](https://github.com/ion-design/dynamite/blob/main/packages/adaptive/src/browser/installer.ts), [runtime](https://github.com/ion-design/dynamite/blob/main/packages/adaptive/src/browser/runtime.ts), [navigation](https://github.com/ion-design/dynamite/blob/main/packages/adaptive/src/browser/navigation.ts), [runtime routes](https://github.com/ion-design/dynamite/blob/main/packages/personalization-server/src/runtime.ts).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.