Comparisons
Cookie banners and page speed: the Core Web Vitals impact
A cookie banner can hurt Core Web Vitals in three ways: it can become the largest element and delay LCP, push content around and add CLS, or make clicks slow and worsen INP. All three are fixable, and a well-built banner can even make pages faster by holding back trackers.
- Plain English
- Written for website owners
- Free to read
On this page
A cookie banner affects Core Web Vitals in three main ways. It can delay Largest Contentful Paint (LCP) if its text becomes the largest element on the screen and renders late. It can cause Cumulative Layout Shift (CLS) if it's inserted into the page flow and pushes content down. And it can worsen Interaction to Next Paint (INP) if clicking a button triggers a burst of heavy work. A small script, a fixed-position overlay and some care with what runs after a click avoid all three.
Core Web Vitals in brief
Google's Core Web Vitals measure loading, interactivity and visual stability from real visitors' Chrome browsers. INP replaced First Input Delay (FID) as the responsiveness metric in March 2024. The "good" thresholds, assessed at the 75th percentile of page loads, are:
| Metric | Measures | Good | Poor | How a banner can affect it |
|---|---|---|---|---|
| LCP | When the largest text block or image in the viewport renders | 2.5 s or less | Over 4 s | The banner becomes the LCP element and renders late |
| INP | Delay from a click, tap or key press to the next frame | 200 ms or less | Over 500 ms | Slow handlers on banner buttons, or tags released all at once |
| CLS | Unexpected movement of visible content | 0.1 or less | Over 0.25 | A banner inserted into the page flow pushes content |
Thresholds have been stable since INP's introduction, but check Google's current documentation if you're reading this later.
How a banner can delay LCP
LCP looks at the largest text block or image visible in the viewport. On a phone, a consent banner with two or three paragraphs of text can be larger on screen than your headline. If so, the banner is the LCP element, and LCP is the moment the banner appears.
That becomes a problem when the banner appears late. A typical sequence: the page's HTML and hero render quickly, the consent script downloads, then fetches its configuration, then draws the banner. If that takes another second, LCP moves a second later, even though your main content was ready.
Ways to fix it:
- Keep the banner script small and early. Load it near the top of the
<head>withasync, so it downloads in parallel with everything else. - Connect early. If the banner loads from another domain, a preconnect hint saves connection setup time:
<link rel="preconnect" href="https://cdn.privacyquick.com">. - Keep the text short. A concise first layer with the details in the preferences panel is better for visitors and less likely to become the largest element.
- Avoid web fonts and images in the banner. Each one is another request before the banner can paint.
Note that LCP stops recording when the visitor first interacts with the page. Real visitors who click the banner quickly cut LCP measurement short, which is one reason lab and field numbers differ.
How a banner causes layout shift
CLS counts content that moves without the visitor causing it. A banner added at the top of the page, inside the normal document flow, pushes everything below it down. If that happens after the visitor can see the content, it's a layout shift. The same is true when the banner is removed and content jumps back up, unless that happens within half a second of the visitor's click, since shifts right after user input aren't counted.
The fix is to keep the banner out of the page flow. A fixed-position overlay sits above the content without moving it:
.consent-banner {
position: fixed;
left: 16px;
right: 16px;
bottom: 16px;
max-width: 560px;
z-index: 1000;
animation: consent-in 200ms ease-out;
}
@keyframes consent-in {
from { transform: translateY(16px); opacity: 0; }
to { transform: none; opacity: 1; }
}
Animate with transform and opacity, not top, height or margin, because those change layout. If you must use a bar in the page flow, reserve its space in your server-rendered HTML so nothing moves when it fills in.
Blocked embeds can cause shifts too. An iframe held back until consent should keep its width and height, or sit in a container with a fixed aspect ratio, so the layout doesn't jump when it loads.
How a banner can worsen INP
INP measures how quickly the page responds to interactions, and the Accept button is often the first one. Clicking it typically writes a cookie, logs the choice, updates Google Consent Mode and releases blocked scripts. If your own code then runs heavy work synchronously in the same handler, such as starting a chat widget or initializing several tags, the browser can't paint the closed banner until it's done.
Defer non-urgent work so the browser can update the screen first:
document.addEventListener('pq:consent', function (e) {
if (e.detail.categories.indexOf('functional') === -1) return;
// Let the browser paint the closed banner, then do the heavier work.
setTimeout(loadChatWidget, 0);
});
Recent Chromium browsers also support scheduler.yield() for the same purpose, with setTimeout as a fallback elsewhere. The scripts released after consent also compete for the main thread during the next few seconds. Each tag you add makes later interactions slower, so review whether you still need every one. Tracking pixels explained covers what common tags actually do.
Script weight and loading strategy
The banner script loads on every page for every visitor, so its size and behavior matter more than most scripts:
- Transfer size. Check the compressed size in the Network tab, including any extra files the script fetches: configuration, translations, vendor lists, stylesheets and fonts.
- Request count. A script that makes several sequential requests before drawing the banner adds round trips, which matter most on mobile connections.
- Render blocking. A synchronous script in the head stops the browser from rendering until it has downloaded and run. Some consent tools recommend synchronous loading so they can block other scripts automatically. Weigh that convenience against the delay, and follow your tool's guidance.
- Main-thread work. Large frameworks bundled into the banner cost parse and execution time, not just bytes.
- Style isolation. A banner that injects global CSS can trigger style recalculation across your page, and your CSS can break it. Rendering in a shadow DOM avoids both.
As a reference point, PrivacyQuick's script is under 5 KB gzipped, has no dependencies, loads with async and draws the banner in a shadow DOM. Measure any tool you consider on your own pages; our guide to choosing a cookie consent tool includes performance in its checklist.
Consent can make pages faster
The performance story isn't only about the banner's own cost. A banner that properly blocks scripts before consent means visitors who reject, or who haven't chosen yet, never download analytics libraries, ad pixels or video players. For many sites, those scripts weigh far more than the banner. Blocking cookies and scripts until consent covers the techniques.
This also affects how you read test results. Lighthouse and PageSpeed Insights lab tests load the page as a new visitor, so they measure the pre-consent state: banner shown, trackers held back. Visitors who accepted get the full set of scripts. Your field data from the Chrome UX Report mixes both groups, so it can look worse than your lab scores. If you use Google Consent Mode's advanced implementation, Google tags load before consent in a restricted mode, which shifts some of that cost to every visitor. Consent Mode basic vs advanced discusses the trade-off.
Measuring the banner's impact
Test both states. For the pre-consent state, use a private window or Lighthouse's default settings. For the post-consent state, accept in a normal window, then run Lighthouse from DevTools with the option to clear storage turned off, so your choice is kept.
To see whether the banner is your LCP element, paste this into the console and reload:
new PerformanceObserver(function (list) {
var entries = list.getEntries();
var last = entries[entries.length - 1];
console.log('LCP candidate', Math.round(last.startTime) + ' ms', last.element);
}).observe({ type: 'largest-contentful-paint', buffered: true });
And to list layout shifts with the elements that moved:
new PerformanceObserver(function (list) {
list.getEntries().forEach(function (entry) {
if (!entry.hadRecentInput) {
console.log('Shift', entry.value.toFixed(4), entry.sources.map(function (s) { return s.node; }));
}
});
}).observe({ type: 'layout-shift', buffered: true });
For INP, record an interaction in the Performance panel of DevTools while clicking Accept, and look for long tasks after the click. Then compare field data in PageSpeed Insights or Search Console over the following weeks, since that's what Google uses.
Performance checklist
- Banner script loads early in the head, without blocking rendering, from a preconnected origin.
- Banner is a fixed-position overlay that animates with transform and opacity only.
- First-layer text is short, with no web fonts or images.
- Held-back embeds keep their dimensions.
- Heavy work after consent is deferred so the click responds quickly.
- Every tag released after consent is still needed.
- Lab tests are run in both the pre-consent and post-consent state, and field data is checked afterwards.
Don't trade compliance for speed. A smaller banner that hides the Reject button may load faster, but it creates a different problem, described in cookie banner dark patterns.
Frequently asked questions
Does a cookie banner affect SEO?
Indirectly. Core Web Vitals are part of the page experience signals Google uses, and a banner that causes layout shift or delays rendering can worsen them. A banner that covers most of the screen on mobile can also make the page harder to use.
Why does Lighthouse show my cookie banner as the LCP element?
Lighthouse loads the page as a first-time visitor, so the banner is always shown. If the banner's text block is larger on screen than your main content, it becomes the largest contentful paint candidate. Make your main content larger in the first viewport or render the banner earlier.
Should the cookie banner script be loaded with async or defer?
Either avoids blocking rendering. async runs the script as soon as it downloads, which helps it set consent defaults before other tags, so many consent tools use it. Follow your tool's documentation, because some depend on running at a particular point.
Do visitors who reject cookies get faster pages?
Often, yes. When the banner blocks analytics, ad and embed scripts until consent, visitors who reject them never download those scripts, which saves network requests and main-thread work.
Check your own website in 30 seconds
Our free scanner lists every cookie and tracker your site sets, sorted into categories, before you add a banner.
This guide is general information, not legal advice. Laws and regulator guidance change; check the current rules for your situation or ask a lawyer.