Feature Library

Cookie consent banner and preferences

<0.01 CPU ms
A still of the Cookie consent banner and preferences demo
Still
The live demo starts when it’s in view.Try Reject all, or Choose and allow one purpose · check what loads · reopen Cookie settings or reset

A non-modal cookie consent banner with equally prominent Accept all and Reject all buttons, opt-in purpose switches, and a privacy link.

A versioned, expiring preference keeps optional scripts and embedded content held until the user allows their purpose.

What it costs a frame

<0.01 ms
GPU
not used
CPU, median
<0.01 ms
CPU, 95th pct
<0.01 ms
Draw calls
0
Weight
Light

Measured 20 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU <0.01–<0.01 ms). What ran: The company page starts with no choice. Real input opens preferences, saves a rejection, reopens and closes the dialog, then resets. The fake analytics and video remain held. Phones: tiers are being measured next.

How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference

Typical frame ?
30.75 ms
1% low ?
31 fps
Varies by ?
±5.85 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.00 ms32.54 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
30.75 ms
p95 ?
31.72 ms
p99 ?
32.29 ms
Slowest ?
32.84 ms
Mean ?
27.93 ms
Standard deviation ?
5.85 ms
1% low ?
31 fps
0.1% low ?
30 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.0 / 0.2 / 0.4 ms

Input

Interactions ?
10
Input to paint ?
2.1 ms, worst 30.2
Longest handler ?
6.0 ms

Memory

JavaScript heap ?
32.6 → 32.1 MB
Growth ?
-0.52 MB

Browser

JavaScript a frame ?
0.08 ms
All tasks a frame ?
0.38 ms
Layout / style ?
0.01 / 0.03 ms
Main thread busy ?
1%

Garbage collection

Collections ?
2 (1 minor, 1 major)
Pauses ?
6.5 ms in all, longest 2.8

What it needs

Renders with
DOM and CSSPlain DOM and CSS: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
With an agent
install("consent-banner")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. Cookie consent banner on a company, product or marketing site
  2. Hold analytics and marketing scripts until consent
  3. Show a video placeholder before loading its iframe
  4. Reopen cookie preferences from a site footer

Pitfalls, in brief

  1. An analytics tag already loaded in head has already run.
  2. Keep Accept all and Reject all equally prominent.
  3. Increase version when a purpose is added or changes meaning.
  4. Gate server-side tags separately.
  5. A script already executed remains executed.
5 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

Written for the library. Adapted from published work, named below.

Hannes Andersson: Feature Library accessible-dialog focus wrapping and scroll lock.

cookie consent bannercookie settingsprivacytracking consentanalyticsmarketingthird-party embedsopt-inaccessible dialoglocalStorageright to left

Near it in the frame