Get the FREE Ultimate OpenClaw Setup Guide →

web-performance-optimization

npx machina-cli add skill Lu1sDV/skillsmd/web-performance-optimization --openclaw
Files (1)
SKILL.md
6.0 KB

Web Performance Optimization

Systematic approach to diagnosing and fixing web performance issues across loading, rendering, and runtime.

Business Impact: 1 second delay = 7% conversion loss. 0.1s improvement = 8% increase in conversions.

When to Use

  • Lighthouse score below 90 or page speed regression
  • Slow LCP (>2.5s), high CLS (>0.1), poor INP (>200ms), high TBT
  • Large JavaScript bundles, render-blocking resources
  • Layout shifts, jank, slow Time to Interactive (TTI)
  • Setting up performance monitoring or budgets
  • Implementing View Transitions, Speculation Rules, Server Components, Islands Architecture

Which Reference Do I Need?

digraph perf_decision {
    rankdir=TB;
    node [shape=box];
    problem [label="What's the problem?" shape=diamond];
    qw [label="quick-wins.md\n1hr/1day/1week optimizations"];
    cwv [label="core-web-vitals.md\nMetric-specific debugging"];
    opt [label="optimization-techniques.md\nJS/CSS/image/caching/backend"];
    mod [label="modern-patterns-2025.md\nView Transitions, Speculation Rules, RSC"];
    fw [label="framework-specific.md\nNext.js, React, Vue, Astro, Svelte"];
    mon [label="monitoring.md\nLighthouse CI, RUM, APM"];

    problem -> qw [label="need fast ROI"];
    problem -> cwv [label="Core Web Vitals failing"];
    problem -> opt [label="bundle/backend/caching"];
    problem -> mod [label="cutting-edge patterns"];
    problem -> fw [label="framework-specific"];
    problem -> mon [label="no visibility"];
}

Performance Budget

ResourceBudgetRationale
Total page weight< 1.5 MB3G loads in ~4s
JavaScript (compressed)< 300 KBParsing + execution time
CSS (compressed)< 100 KBRender blocking
Images (above-fold)< 500 KBLCP impact
Fonts< 100 KBFOIT/FOUT prevention
Third-party< 200 KBUncontrolled latency

Core Web Vitals at a Glance

MetricTargetLighthouse WeightKey Optimization
LCP (Largest Contentful Paint)<2.5s25%Optimize images, preload critical resources
INP (Interaction to Next Paint)<200ms30%Reduce JavaScript, break up long tasks
CLS (Cumulative Layout Shift)<0.125%Reserve space, optimize fonts
TBT (Total Blocking Time)<200ms30%Code splitting, defer non-critical JS
FCP (First Contentful Paint)<1.8s10%Eliminate render-blocking resources

-> See core-web-vitals.md for debugging workflows per metric

Quick Wins (by time investment)

TimeOptimizationImpact
1hrloading="lazy" on below-fold images40-60% weight reduction
gzip/brotli compression70-80% transfer reduction
rel="preconnect" for critical origins100-500ms savings
width/height on imagesPrevents CLS
1dayRoute-based code splitting30-50% bundle reduction
LCP image: fetchpriority="high" + WebP/AVIF200-400ms LCP improvement
Basic service workerInstant repeat visits
1wkFull HTTP + service worker cachingReduced server load
Tree shaking + dead code elimination40-60% bundle reduction
Lighthouse CI + RUM monitoringCatch regressions

-> See quick-wins.md for implementation details

Runtime Performance Checklist

  • Batch DOM reads/writes to avoid layout thrashing
  • Debounce scroll/resize handlers (100ms+)
  • Use requestAnimationFrame for animations (not setInterval)
  • Virtualize long lists (1000+ items): content-visibility: auto or react-window/@tanstack/virtual
  • Avoid synchronous third-party scripts

-> See optimization-techniques.md for backend, image, JS, CSS, and caching techniques

Modern Patterns (2025)

PatternKey BenefitComplexity
View TransitionsSmooth page transitions, zero JS costLow
Speculation Rules0ms navigation via prerenderingLow
Server ComponentsZero-bundle server-only componentsMedium
Priority Hintsfetchpriority="high" for LCPLow
content-visibility7x faster rendering for long pagesLow
Islands Architecture90-99% less JS shippedHigh

-> See modern-patterns-2025.md for implementation details

Red Flags

Stop and reconsider if:

  • Optimizing without baseline measurement
  • Focusing only on Lighthouse score (ignoring field/RUM data)
  • Ignoring mobile performance (53% abandon after 3s)
  • Loading all resources eagerly (no lazy loading)
  • No caching strategy implemented
  • Third-party scripts loaded synchronously
  • Missing performance monitoring/budgets
  • Layout thrashing in scroll/resize handlers
  • Long tasks (>50ms) blocking main thread

Real-World Impact

  • Pinterest: 40% faster perceived wait = 15% more sign-ups + 15% more SEO traffic
  • Zalando: 0.1s improvement = 0.7% revenue increase
  • AutoAnything: 50% faster load = 12-13% sales increase
  • Core Web Vitals are Google ranking factors (June 2021+)

References

Source

git clone https://github.com/Lu1sDV/skillsmd/blob/main/web-performance-optimization/SKILL.mdView on GitHub

Overview

Web Performance Optimization provides a systematic approach to diagnosing and fixing performance issues across loading, rendering, and runtime. It emphasizes business impact (1s delay = 7% conversions) and offers budgets, core web vitals targets, and modern patterns like View Transitions and Speculation Rules to boost Lighthouse scores and UX.

How This Skill Works

The skill guides you through problem framing, budgeting, and technique selection using reference docs such as core-web-vitals.md, optimization-techniques.md, and quick-wins.md. It combines quick wins with advanced patterns (code splitting, Islands Architecture, View Transitions) and relies on monitoring tools like Lighthouse CI and RUM to detect regressions and validate improvements.

When to Use It

  • Lighthouse score below 90 or page speed regression
  • Slow LCP (>2.5s), high CLS (>0.1), poor INP (>200ms), or high TBT
  • Large JavaScript bundles and render-blocking resources
  • Layout shifts, jank, or slow Time to Interactive (TTI)
  • Setting up performance monitoring or budgets

Quick Start

  1. Step 1: Audit with performance budgets, Core Web Vitals targets, and current Lighthouse scores.
  2. Step 2: Apply Quick Wins such as lazy loading below-fold images, gzip/brotli compression, preconnect hints, and setting width/height on images.
  3. Step 3: Enable monitoring (Lighthouse CI, RUM) and establish budgets to detect regressions.

Best Practices

  • Set up a Performance Budget for total page weight and critical assets (e.g., total weight < 1.5 MB, JS < 300 KB, CSS < 100 KB, images < 500 KB).
  • Target Core Web Vitals: LCP < 2.5s, CLS < 0.1, INP < 200ms, TBT < 200ms, FCP < 1.8s, and monitor with Lighthouse weights.
  • Prioritize Quick Wins by time investment (1hr, 1 day, 1 week) and execute them first.
  • Follow the Runtime Performance Checklist to minimize layout thrash and unnecessary JS execution.
  • Adopt modern patterns (View Transitions, Speculation Rules, Server Components/Islands) and monitor with Lighthouse CI and RUM.

Example Use Cases

  • An e-commerce product page reduces weight and improves LCP by optimizing images, preloading critical resources, and removing render-blocking CSS.
  • A site shrinks JS/CSS bundles to meet a <1.5 MB total budget, cutting TBT and boosting CLS stability.
  • Lighthouse CI + RUM monitoring catches regressions after a refactor and preserves Core Web Vitals targets.
  • Route-based code splitting and fetchpriority="high" for LCP images deliver 30-50% bundle reduction and faster load times.
  • Implementing View Transitions and Speculation Rules on a modern SPA smooths UX and reduces visual instability during navigations.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers