Eliminating Mobile Cumulative Layout Shift (CLS) on Tailwind & Alpine.js Websites
A 99/100 Desktop PageSpeed score does not save you if Mobile CLS sits at 0.21. Here are the exact causes of mobile layout shift—webfont swap, unsized logos, and Alpine x-cloak—and how to zero them out.
Google evaluates Core Web Vitals primarily on mobile devices, and Cumulative Layout Shift (CLS) must stay at or below 0.10 to pass. It is surprisingly common to see a website score 99 on Desktop Lighthouse while failing Mobile CLS at 0.20+.
1. Webfont Swap Pushing Above-the-Fold Headlines
If your @font-face rules use font-display: swap with a geometric display font like Plus Jakarta Sans, mobile browsers initially render your <h1> in system Arial or Roboto. Three hundred milliseconds later, when the WOFF2 file finishes loading, the wider font glyphs wrap your headline from 3 lines to 4 lines—shoving every button and stats card below it downward.
Because we self-host our WOFF2 subsets and preload them in <head> with <link rel="preload" as="font" type="font/woff2" crossorigin>, switching font-display: swap to font-display: optional eliminates font-swap layout shifts completely:
@font-face {
font-family: 'Plus Jakarta Sans';
font-style: normal;
font-weight: 600 800;
font-display: optional;
src: url('/fonts/plus-jakarta-sans-latin.woff2') format('woff2');
}
2. Always Declare Intrinsic width and height on Every <img>
Even a small 8KB header logo causes layout reflow if the browser does not know its aspect ratio before the image bytes arrive. Add the exact intrinsic pixel dimensions directly to the HTML tag while letting Tailwind classes control display sizing:
<img
src="/images/brand/logo-monogram-light.png"
alt=""
width="200"
height="237"
class="h-8 sm:h-9 w-auto object-contain shrink-0"
loading="eager"
/>
3. Prevent Alpine.js Hydration Jumps with x-cloak
Define [x-cloak] { display: none !important; } in your main CSS bundle and attach x-cloak to dropdowns, mobile drawers, and modals so they never flash open for 100ms before Alpine boots and collapses them. For mobile touch accessibility, also make sure carousel pagination dots sit inside a min-w-[44px] min-h-[44px] button wrapper so Lighthouse's target-size audit passes at 100%.
Need help architecting a Laravel backend, Kotlin Android app, or joining our weekend engineering cohort?