Fix Cumulative Layout Shift (CLS) — Lovable
CLS happens when content jumps during load — you click something and hit the wrong element. Google penalizes it; users hate it.
Fixing this in Lovable
AI full-stack app builder (React + Vite + Supabase)
Lovable apps ship fast but skip most SEO and security basics out of the box. Paste the prompt below into your Lovable chat and the fix rolls out across the project in one pass.
Using a different tool? Pick your stack:
The prompt for Lovable
Copy and paste this into your Lovable chat exactly as-is.
Fix my Lovable app — please make these exact changes in the Lovable editor: Fix Cumulative Layout Shift 1. Add explicit width and height to all images and video elements. 2. Avoid inserting content above existing content dynamically. 3. Use font-display: swap for web fonts.
Why this matters
CLS is the "janky load" metric. When images load without declared dimensions, the page height jumps — and users often click the wrong button mid-shift.
Core Web Vital — Google rewards CLS < 0.1 and penalizes > 0.25. Easy fix: explicit dimensions everywhere.
How to use this prompt in Lovable
- 1. Open your Lovable project.
- 2. Copy the prompt above with the copy button.
- 3. Paste into the Lovable chat and send.
- 4. Review the diff, accept the changes, redeploy.
- 5. Verify the fix using the checklist below.
Common mistakes to avoid
- error_outlineImages without width/height — the #1 cause of CLS.
- error_outlineLate-loading web fonts that swap and shift text.
- error_outlineInjecting banner/cookie notices above existing content.
- error_outlineAdding ads or embeds without reserved space.
How to verify the fix worked
- check_circlePageSpeed Insights → CLS < 0.1.
- check_circleDevTools Performance → Experience → Layout Shift events — none over 0.05.
- check_circleRecord a slow mobile load (4G throttle) — no visible jumps.
Frequently asked questions
How do I set dimensions on responsive images?expand_more
font-display: swap or optional?expand_more
Want all 34 prompts tailored to your Lovable site?
Pantra scans your site in 10 seconds, detects the stack, and generates the exact prompts that apply — only the ones you actually need.
Scan my siteRelated Lovable prompts
Improve Largest Contentful Paint (LCP) — Lovable
Prompt to get LCP under 2.5 seconds — preload the hero image, cut render-blocking, use a proper CDN.
PerformanceImprove Interaction to Next Paint (INP) — Lovable
Prompt to get INP under 200ms — split long tasks, lazy-load heavy JS, debounce handlers.
PerformanceFix Core Web Vitals (LCP, CLS, INP) — Lovable
Prompt to address Google Core Web Vitals thresholds: LCP < 2.5s, CLS < 0.1, INP < 200ms. Works in any AI-coded stack.