SquishPixel Blog · Core Web Vitals · Web performance · Front-end

A cookie banner logo, not the hero image, was dragging down LCP on a network of sites

According to DEV Community, a network of content sites had poor Largest Contentful Paint (LCP) even after real work on hero images. LCP is the Core Web Vitals measure of when the largest piece of content finishes painting. The team had fixed image sizing, format and preload hints, but the number did not change.

The breakthrough came from reading the Lighthouse trace's element path closely. The flagged LCP element was not in the article at all. It was a logo inside a consent-management overlay. A consent-management platform (CMP) is the third-party script that shows the cookie and privacy banner. Because the banner rendered early and its logo was larger than anything else on screen, both Lighthouse and Chrome's CrUX field data counted it as the LCP element.

The cause was a setting. The CMP script, about 55KB of JavaScript plus half a dozen extra network requests, loaded on every page view whether or not the visitor had already made a consent choice. A dashboard toggle to gate script loading behind consent was off, and a custom JavaScript block in the same dashboard loaded the script unconditionally. Nothing in the codebase or deploy history touched it. The post also notes that a tracking note claiming a ticket had been filed turned out to be false.

The fix was to turn on the gating setting, or at least defer loading off the critical path, and to shrink the overlay's logo. The author then measured four sites sharing the same CMP configuration, using repeated warm runs. Two improved meaningfully. Two did not move, because their real hero images were already larger than the banner logo, so the banner was never the bottleneck there.

Why it matters

Much of what loads on a page is configured outside your code. Consent tools, tag managers, A/B testing tools and analytics are often set up in a vendor's dashboard. They can hurt Core Web Vitals as much as your own code, and a code review or a search of your repository will never show them.

The post also shows two habits worth copying. Read which element the tool says is being measured, not just the score. And test a fix on every affected page, since the same problem can matter a lot on one page and not at all on another.

Do not assume someone has already reported a problem. Check that a ticket really exists.

Source: DEV Community. This brief summarises their reporting; read the original for the full detail.