DEV Community

Oxymore Services
Oxymore Services

Posted on

Fixing Core Web Vitals for a Shopify Theme in a Day: a Real Playbook

Fixing Core Web Vitals for a Shopify Theme in a Day: a Real Playbook

Last month a Shopify client came to us at Oxymore Services with a Core Web Vitals report so red it looked like a crime scene. LCP 5.8s on mobile, CLS 0.34, INP 420ms. Google Search Console was screaming about mobile usability. Organic traffic down 18% quarter over quarter.

One working day later: LCP 1.9s, CLS 0.04, INP 140ms. All three metrics in the green. Here's the playbook.


The starting point

Shopify's Dawn-derived theme with 8 apps installed, a Klaviyo popup, a video hero on the homepage, three sliders on PDPs, and a chat widget. Standard setup. Standard disaster.

I like to start by measuring the field data from Search Console, not PageSpeed lab scores. Lab lies about mobile performance on fast connections. Field data is what Google ranks on.

Fix #1: the video hero

The homepage hero was a 12 MB autoplay MP4. It was blocking LCP by 3.4 seconds alone.

Replaced with a WebM + poster-image combo:

  • Poster image, 180 KB, WebP, with fetchpriority="high" in the <img> tag
  • Video preload="none" + "play when in viewport" via IntersectionObserver
  • Fallback MP4 only for Safari

LCP dropped from 5.8s to 2.4s on this single change. The hero still looks animated after first paint; the user can't tell.

Fix #2: evict the heavy apps

Shopify apps inject their own scripts into every page. 8 apps = ~1.3 MB of JavaScript shipped before first interaction.

We audited each with the Shopify Theme Inspector:

  • Loox reviews: kept, deferred on PDPs only
  • Klaviyo: kept, deferred by 3s on first page load
  • Four apps that "did nothing visible" but still shipped bundles: uninstalled
  • Instagram feed app: replaced with a static grid of 6 images (saved 420 KB)
  • Currency converter: replaced with a 2-line IntersectionObserver that lazy-loads the rate

INP went from 420ms to 180ms after this round.

Fix #3: fix CLS from banners and popups

CLS was coming from three places:

  1. Announcement bar loading late and pushing hero down (CLS +0.14)
  2. Klaviyo popup injecting into the DOM after 2 seconds (CLS +0.11)
  3. Product-image gallery resizing on load (CLS +0.09)

Fixes:

  • Announcement bar: fixed height reserved in CSS (height: 44px; on container, visible or not)
  • Klaviyo popup: positioned fixed, not inline-inserted
  • Gallery: explicit width + height on every <img>, aspect-ratio locked to 1:1

CLS dropped to 0.04. Google considers anything under 0.1 "Good".

Fix #4: INP from the chat widget

The chat widget (Gorgias) was eating 180ms of main-thread time on every click because its button handler was synchronous and heavy.

We switched to a "deferred widget" pattern:

  1. Render a lightweight placeholder button (12 lines of CSS, no JS)
  2. On first user interaction OR 10 seconds of idle, dynamically import the real widget
  3. First real click hands off to the loaded widget

INP settled at 140ms. Chat support never noticed.

Fix #5: image format and sizing

Shopify's native {{ product.featured_image }} emits large JPEGs by default. We added size parameters everywhere:

{{ product.featured_image | image_url: width: 800, height: 800, format: 'webp' }}
Enter fullscreen mode Exit fullscreen mode

Paired with loading="lazy" on everything below the fold and loading="eager" + fetchpriority="high" on the hero image.

Average page weight dropped from 4.2 MB to 1.1 MB.


Day 2: measure, iterate

48 hours after deploying the fixes, Search Console's field data caught up and all three metrics flipped green. Three weeks later organic sessions were back above baseline.

The lesson isn't "apps are bad." It's that every app and every theme feature has a cost, and that cost has to be budgeted against the metrics Google actually ranks on.

If you want us to run a Core Web Vitals sprint on your store, we do them at Oxymore Services — flat price, one-week turnaround, US-based team.

What's the biggest Shopify perf win you've shipped?

Top comments (0)