The banner nobody performance-tested
A consent banner is legally required for many sites, added by marketing or legal, from a vendor whose product is compliance, not speed. It loads on every page, before anything else has a chance, and it is one of the most common reasons an otherwise well-built site fails Core Web Vitals. On many audits it is the top cause of layout shift and a leading cause of slow interactions.
None of that is inherent to consent. It is how the banner is loaded and what happens when it is clicked.
The three costs
Layout shift. The banner is injected by a script after the page has rendered, as a bar at the top or bottom that pushes content. Every visitor on every first visit sees the page jump. That is CLS, often 0.1 to 0.3 on its own, on every page, which is enough to fail the metric site-wide.
Load and main-thread cost. The consent vendor's script is often 100 to 300 kilobytes, loaded synchronously or early, executing before the page is interactive. It delays LCP by competing for the connection and adds input delay to any early tap.
The Accept avalanche. The visitor taps Accept. The consent manager fires its callbacks and every gated tag loads at once: tag manager, analytics, ads, pixels, heat maps, chat. The main thread is saturated for a second or more. The tap on Accept, and anything the visitor tries next, is slow. This is the INP problem, and it is very common in field attribution: the Accept button is the slowest interaction on the site.
Fixing layout shift
The banner must not move content. Two acceptable designs:
- Overlay. Fixed position, at the bottom or as a centred modal, layered over the page. Content beneath does not move. This is how most well-built banners work.
- Reserved space. If the design demands a bar that pushes content, reserve the space in the initial HTML and CSS so the page is laid out with the bar's height from the first paint, and the bar fills the reserved space when it renders. Rarely worth the complexity; use an overlay.
Render the banner's markup server-side, or in the initial HTML, with its visibility controlled by a class the consent script toggles. A banner that exists in the HTML and is shown by CSS does not shift anything. A banner injected by JavaScript into a page that has already painted does, unless it is a fixed overlay.
Check with DevTools' Layout Shift track: the banner's appearance should produce no shift record.
Fixing load cost
Self-host or defer the vendor script. Load it with defer or after the page is interactive. The banner does not need to appear in the first 100 milliseconds; it needs to appear before the visitor does anything that requires consent, which on most sites is nothing until they interact. A banner appearing 500 milliseconds after content is fine.
Use a light implementation. Many vendors offer a lightweight loader that shows the banner and loads the full consent management platform only when the visitor opens the preferences panel. Some open-source consent libraries are under 10 kilobytes. For a business site with a handful of tags, a small custom banner storing a consent cookie and gating tags is legitimate and compliant if it meets the legal requirements (granular choices, reject as easy as accept, records of consent where required).
Do not block rendering on it. No synchronous script in the head; no blocking stylesheet from the vendor's domain. Inline the banner's CSS; it is small.
Fixing the Accept avalanche
The Accept handler should do the minimum synchronously, paint, and then load tags gradually.
- Store consent and hide the banner. A cookie write and a class toggle. Milliseconds. The page paints the banner's disappearance; INP for the tap is now measured, and it is fast.
- Yield.
setTimeout(..., 0),scheduler.yield(), orrequestIdleCallbackbefore loading anything. - Load tags in priority order with gaps. Analytics first, since it is the one the business needs; then the tag manager, which itself should be configured to load its tags on triggers rather than all at once; then marketing pixels; then heavy things like heat maps and session replay, ideally only after the visitor has been on the page for a few seconds or scrolled.
With Google Tag Manager, use Consent Mode so tags are configured once and wait for the consent signal, and configure heavy tags to fire on a delayed trigger (timer or scroll) rather than on the consent event itself.
Check in field attribution: the Accept button should no longer appear in poor INP interactions. In the lab, a Performance recording of clicking Accept should show a short task for the click and then a spread of later tasks, not one block.
Do not gate the site on consent
Some banners block interaction with the page, or blur it, until a choice is made. Beyond the legal questions (in several jurisdictions this is not permitted), it is a performance disaster: the visitor's first interaction is forced to be the banner, on a page still loading. An overlay that permits scrolling and reading beneath it is better for compliance and for every metric.
Returning visitors
Once consent is stored, the banner should not render at all and gated tags should load per the stored choice, again gradually and after the page is interactive. Check that the vendor script does not still load its full bundle for a visitor who consented last week; several do.
Checklist
- Banner is a fixed overlay or has reserved space: zero layout shift.
- Banner markup is in the initial HTML; script is deferred.
- Vendor script is lightweight, or full CMP loads only on preferences.
- Accept handler: store, hide, yield, then load tags in priority order with gaps.
- Tag manager configured with Consent Mode and delayed triggers for heavy tags.
- Site is usable beneath the banner.
- Returning visitors: no banner render, no full CMP load.
Where this fits
The consent banner is one of the first things we look at in a Core Web Vitals audit, because it is so often the largest single cause of both CLS and INP failures and because fixing it requires no change to the site's own code, only to how a third-party is loaded and what happens on one click. Compliance and speed are not in tension here; the slow banner is usually also the one that is hardest to reject, and both problems have the same fix.