fix: Improve Core Web Vitals (LCP and CLS) #48

Closed
opened 2026-04-05 16:18:45 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @simlarsen on 3/4/2026

Summary

  • Fixes Desktop CLS (0.21 → <0.1) on 35 /docs URLs by removing redundant Tailwind CDN — the compiled CSS in style.css already contains all needed utilities; the CDN was re-processing styles and causing layout shifts
  • Fixes Mobile LCP (2.7s → <2.5s) on 311 URLs by deferring PostHog analytics via requestIdleCallback, reducing Google Fonts to only used weights (400–800), moving <meta charset>/<meta viewport> to top of <head>, and adding defer to highlight.js on blog posts
  • Adds DNS prefetch for PostHog domain to keep analytics latency low after deferral

Test plan

  • Verify /docs pages render correctly without Tailwind CDN (all styles come from compiled style.css)
  • Verify homepage, pricing, blog, and about pages still render correctly with deferred PostHog
  • Confirm PostHog analytics events (page_view, CTA clicks, UTM tracking) still fire after deferral
  • Run PageSpeed Insights on /pricing (mobile) to verify LCP < 2.5s
  • Run PageSpeed Insights on /docs (desktop) to verify CLS < 0.1
  • After deploy, click "Validate Fix" in Google Search Console for both issues

🤖 Generated with Claude Code

*Originally created by @simlarsen on 3/4/2026* ## Summary - **Fixes Desktop CLS** (0.21 → <0.1) on 35 `/docs` URLs by removing redundant Tailwind CDN — the compiled CSS in `style.css` already contains all needed utilities; the CDN was re-processing styles and causing layout shifts - **Fixes Mobile LCP** (2.7s → <2.5s) on 311 URLs by deferring PostHog analytics via `requestIdleCallback`, reducing Google Fonts to only used weights (400–800), moving `<meta charset>`/`<meta viewport>` to top of `<head>`, and adding `defer` to highlight.js on blog posts - Adds DNS prefetch for PostHog domain to keep analytics latency low after deferral ## Test plan - [ ] Verify `/docs` pages render correctly without Tailwind CDN (all styles come from compiled `style.css`) - [ ] Verify homepage, pricing, blog, and about pages still render correctly with deferred PostHog - [ ] Confirm PostHog analytics events (page_view, CTA clicks, UTM tracking) still fire after deferral - [ ] Run PageSpeed Insights on `/pricing` (mobile) to verify LCP < 2.5s - [ ] Run PageSpeed Insights on `/docs` (desktop) to verify CLS < 0.1 - [ ] After deploy, click "Validate Fix" in Google Search Console for both issues 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#48