Audit and optimize Core Web Vitals (LCP, INP, CLS), bundle size, loading strategy, and rendering pipeline. Use when user asks to "optimize performance", "improve Core Web Vitals", "reduce bundle size", or "fix slow page load".
From sovereign-architectnpx claudepluginhub javimontano/mao-sovereign-architectThis skill is limited to using the following tools:
agents/bundle-analyzer-agent.mdagents/loading-strategy-agent.mdagents/web-performance-agent.mdevals/evals.jsonexamples/sample-output.mdprompts/use-case-prompts.mdreferences/body-of-knowledge.mdreferences/knowledge-graph.mmdreferences/state-of-the-art.mdSystematically measure, diagnose, and optimize web application performance across loading, interactivity, and visual stability dimensions.
"Optimize what you measure, measure what matters to users. Core Web Vitals are user-experience metrics first, technical metrics second."
web-vitals JS library in production with real user monitoring (RUM):
import { onLCP, onINP, onCLS } from 'web-vitals';
onLCP(console.log); onINP(console.log); onCLS(console.log);
npx webpack-bundle-analyzer dist/stats.json or Vite's --analyze.[HECHO] with timestamp and test conditions.CWV Thresholds (Good / Needs Improvement / Poor):
| Metric | Good | Needs Improvement | Poor |
|---|---|---|---|
| LCP (Largest Contentful Paint) | ≤ 2.5s | 2.5–4.0s | > 4.0s |
| INP (Interaction to Next Paint) | ≤ 200ms | 200–500ms | > 500ms |
| CLS (Cumulative Layout Shift) | ≤ 0.1 | 0.1–0.25 | > 0.25 |
| TTFB (Time to First Byte) | ≤ 800ms | 800–1800ms | > 1800ms |
| FCP (First Contentful Paint) | ≤ 1.8s | 1.8–3.0s | > 3.0s |
<link rel="preload" as="style"><head><link rel="preload" as="image" href="/hero.webp" fetchpriority="high">
loading="lazy" from LCP image — it delays discovery.srcset.scheduler.yield() or setTimeout(0).<script defer> or <script type="module">.@tanstack/react-virtual or similar — never render 1000+ DOM nodes.new Worker('/worker.js') for CPU-intensive operations.// Break up long task with scheduler.yield()
async function processLargeDataset(items) {
for (let i = 0; i < items.length; i++) {
processItem(items[i]);
if (i % 50 === 0) await scheduler.yield(); // yield every 50 items
}
}
<img src="photo.jpg" width="800" height="600" alt="...">
.ad-slot { min-height: 250px; }
transform for animations instead of top/left/width/height — transforms don't trigger layout.font-display: optional or size-adjust to prevent layout shift from font swap.vite build --analyze or webpack --profile --json > stats.json.// React Router / Next.js
const Dashboard = lazy(() => import('./pages/Dashboard'));
import *.moment.js → date-fns (modular, tree-shakeable)lodash → native ES2025 or lodash-esaxios → fetch + ky for interceptorsmodulepreload for next-likely routes.<link rel="preconnect"> for third-party origins (fonts, APIs, CDN)<link rel="dns-prefetch"> for domains you'll need later<link rel="preload"> for critical resources needed in < 3 seconds<link rel="prefetch"> for resources needed on next navigationtype="module" — deferred, modern browsers onlydefer — deferred, good for legacy supportasync — for analytics, ads (not render-critical)web-vitals reporting to production monitoring dashboard.| LCP > 4s | Fix TTFB, preload LCP image, eliminate render-blocking resources |
|---|---|
| INP > 500ms | Profile long tasks, defer JS, virtualize lists |
| CLS > 0.25 | Add dimensions to images, reserve space for dynamic content |
| Bundle > 500KB | Code splitting, tree shaking, dependency audit |
| TTFB > 1800ms | CDN, server caching, Edge rendering, database query optimization |
| Resource | Cache Strategy | Max-Age |
|---|---|---|
| HTML | No-cache (revalidate) | 0 |
| CSS/JS with hash | Cache-first | 1 year |
| Images | Cache-first | 30 days |
| API responses | Stale-while-revalidate | Per endpoint |
| Fonts | Cache-first | 1 year |
loading="lazy" on LCP image — Delays discovery by the browser's preload scanner. LCP images must be eager.preload everything — Creates bandwidth contention. Preload only 1-3 critical resources per page.requestAnimationFrame for non-visual work — rAF fires at 60fps = every 16ms. Use setTimeout or Workers for non-visual tasks.performance-audit-{date}.md — Baseline measurement reportperformance-budget.json — Bundle size and CWV thresholds for CIsrc/workers/heavy-task.worker.ts — Web Worker for CPU-intensive workADR-PERF-001.md — Performance architecture decisionsDesigns and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.