Skilllibrary frontend-performance
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/08-web-frontend-and-design/frontend-performance" ~/.claude/skills/merceralex397-collab-skilllibrary-frontend-performance && rm -rf "$T"
manifest:
08-web-frontend-and-design/frontend-performance/SKILL.mdsource content
Purpose
Optimize Core Web Vitals (LCP, CLS, INP) and Lighthouse performance score through bundle optimization, image handling, and rendering strategies.
When to use this skill
- diagnosing slow LCP, layout shifts (CLS), or interaction delays (INP)
- reducing bundle size with code splitting and tree shaking
- implementing image optimization and lazy loading
- improving Lighthouse performance score
Do not use this skill when
- the task is backend/API performance — different domain
- the task is accessibility — prefer
accessibility-audit - the task is SEO metadata — prefer
seo-structured-data
Procedure
- Measure baseline — run Lighthouse in incognito:
. Note LCP, CLS, INP, TBT.npx lighthouse <url> --output=json - Analyze bundle —
ornpx webpack-bundle-analyzer
. Find largest chunks.npx vite-bundle-visualizer - Code split routes —
+React.lazy()
for route-level splitting. DynamicSuspense
for heavy features.import() - Optimize images — use
with<img>
,srcset
, andsizes
. Serve WebP/AVIF. Set explicitloading="lazy"
/width
to prevent CLS.height - Reduce CLS — reserve space for dynamic content (ads, images, embeds) with
or explicit dimensions.aspect-ratio - Improve INP — break long tasks with
orrequestIdleCallback
. Debounce input handlers.scheduler.yield() - Optimize fonts — use
, preload critical fonts:font-display: swap
.<link rel="preload" as="font" crossorigin> - Verify — re-run Lighthouse. Test on throttled 3G in DevTools. Check field data in CrUX/PageSpeed Insights.
Core Web Vitals targets
| Metric | Good | Needs Work | Poor |
|---|---|---|---|
| LCP | < 2.5s | 2.5-4s | > 4s |
| CLS | < 0.1 | 0.1-0.25 | > 0.25 |
| INP | < 200ms | 200-500ms | > 500ms |
Code splitting pattern
import { lazy, Suspense } from 'react'; const Dashboard = lazy(() => import('./pages/Dashboard')); const Settings = lazy(() => import('./pages/Settings')); function App() { return ( <Suspense fallback={<Spinner />}> <Routes> <Route path="/" element={<Dashboard />} /> <Route path="/settings" element={<Settings />} /> </Routes> </Suspense> ); }
Image optimization
<img src="/img/hero.webp" srcset="/img/hero-400.webp 400w, /img/hero-800.webp 800w, /img/hero-1200.webp 1200w" sizes="(max-width: 768px) 100vw, 50vw" width="1200" height="600" loading="lazy" decoding="async" alt="Hero image" />
Decision rules
- Measure before optimizing — Lighthouse + field data (CrUX), not guesses.
- LCP is usually the hero image or largest text block — optimize that first.
- Set explicit dimensions on all images and embeds — prevents CLS.
- Preload only critical resources — over-preloading delays everything.
- Third-party scripts (analytics, chat widgets) are the top CLS/TBT offender — load them after interaction or on
.requestIdleCallback
References
Related skills
— a11y alongside performanceaccessibility-audit
— performance affects SEOseo-structured-data
— analytics script impactanalytics-instrumentation