WE

web-performance-optimization

Improves web application performance and Core Web Vitals.

Install

mkdir -p .claude/skills/web-performance-optimization-comeonoliver && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11052" && unzip -o skill.zip -d .claude/skills/web-performance-optimization-comeonoliver && rm skill.zip

Installs to .claude/skills/web-performance-optimization-comeonoliver

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Optimizes web application performance through code splitting, lazy loading, caching strategies, and Core Web Vitals monitoring. Use when improving page load times, implementing service workers, or reducing bundle sizes.
219 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Implement code splitting
  • Enable lazy loading
  • Configure caching strategies
  • Monitor Core Web Vitals
  • Optimize image delivery

How it works

It applies strategies like lazy loading, code splitting, and caching to improve page load times and Core Web Vitals.

Inputs & outputs

You give it
Web application codebase
You get back
Optimized performance metrics

When to use web-performance-optimization

  • Reducing bundle sizes
  • Optimizing Core Web Vitals
  • Improving LCP and CLS
  • Implementing lazy loading

About this skill

Web Performance Optimization

Overview

Implement performance optimization strategies including lazy loading, code splitting, caching, compression, and monitoring to improve Core Web Vitals and user experience.

When to Use

  • Slow page load times
  • High Largest Contentful Paint (LCP)
  • Large bundle sizes
  • Frequent Cumulative Layout Shift (CLS)
  • Mobile performance issues

Code Splitting (React)

import { lazy, Suspense } from 'react';
import { Routes, Route } from 'react-router-dom';

const Home = lazy(() => import('./pages/Home'));
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Settings = lazy(() => import('./pages/Settings'));

function App() {
  return (
    <Suspense fallback={<Loading />}>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/dashboard" element={<Dashboard />} />
        <Route path="/settings" element={<Settings />} />
      </Routes>
    </Suspense>
  );
}

Webpack Bundle Optimization

// webpack.config.js
module.exports = {
  optimization: {
    splitChunks: {
      chunks: 'all',
      cacheGroups: {
        vendor: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendors',
          chunks: 'all'
        }
      }
    }
  }
};

Image Optimization

<picture>
  <source srcset="image.webp" type="image/webp">
  <source srcset="image.jpg" type="image/jpeg">
  <img
    src="image.jpg"
    srcset="image-400.jpg 400w, image-800.jpg 800w, image-1200.jpg 1200w"
    sizes="(max-width: 600px) 100vw, 50vw"
    loading="lazy"
    decoding="async"
    alt="Description"
  >
</picture>

Service Worker Caching

// sw.js
const CACHE_NAME = 'app-v1';
const ASSETS = ['/', '/index.html', '/main.js', '/styles.css'];

self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS))
  );
});

self.addEventListener('fetch', (event) => {
  event.respondWith(
    caches.match(event.request).then(cached => {
      return cached || fetch(event.request).then(response => {
        return caches.open(CACHE_NAME).then(cache => {
          cache.put(event.request, response.clone());
          return response;
        });
      });
    })
  );
});

Core Web Vitals Monitoring

// Track LCP, CLS, INP (Note: INP replaced FID as of March 2024)
// sendToAnalytics is a placeholder function that sends metrics to your analytics endpoint
// Expected signature: sendToAnalytics({ metric: string, value: number }) => void
// Example implementation:
function sendToAnalytics({ metric, value }) {
  // Replace with your analytics implementation (e.g., Google Analytics, Segment)
  fetch('/api/analytics', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ metric, value, timestamp: Date.now() })
  });
}

// Largest Contentful Paint (LCP)
new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    console.log(`LCP: ${entry.startTime}ms`);
    sendToAnalytics({ metric: 'LCP', value: entry.startTime });
  }
}).observe({ type: 'largest-contentful-paint', buffered: true });

// Cumulative Layout Shift (CLS)
new PerformanceObserver((list) => {
  let cls = 0;
  for (const entry of list.getEntries()) {
    if (!entry.hadRecentInput) cls += entry.value;
  }
  sendToAnalytics({ metric: 'CLS', value: cls });
}).observe({ type: 'layout-shift', buffered: true });

// Interaction to Next Paint (INP) - replaces FID
new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    // INP measures responsiveness - duration of slowest interaction
    const inp = entry.processingEnd - entry.processingStart;
    console.log(`INP: ${inp}ms`);
    sendToAnalytics({ metric: 'INP', value: inp });
  }
}).observe({ type: 'event', buffered: true }); // 'event' captures interaction events

Performance Targets

MetricGoodNeeds Improvement
LCP<2.5s2.5-4s
INP<200ms200-500ms
CLS<0.10.1-0.25
TTI<3.8s3.8-7.3s

Note: INP (Interaction to Next Paint) replaced FID (First Input Delay) as a Core Web Vital in March 2024. INP provides a more comprehensive measure of page responsiveness by capturing the full duration of interactions, not just the input delay.

Compression (Nginx)

gzip on;
gzip_types text/plain text/css application/json application/javascript;
gzip_min_length 1000;
gzip_comp_level 6;

Best Practices

  • Minimize bundle size with code splitting
  • Optimize images with appropriate formats
  • Implement lazy loading strategically
  • Use HTTP caching headers
  • Enable gzip/brotli compression
  • Monitor Core Web Vitals continuously
  • Implement service workers
  • Defer non-critical JavaScript
  • Optimize critical rendering path
  • Test on real devices and networks

Optimization Checklist

  • Enable code splitting for routes
  • Lazy load below-fold components
  • Optimize and compress images
  • Implement service worker caching
  • Enable gzip/brotli compression
  • Monitor Core Web Vitals
  • Minimize render-blocking resources

Additional Configuration

See references/compression-monitoring.md for:

  • Webpack compression plugin setup
  • Apache .htaccess compression config
  • TTFB monitoring implementation
  • Puppeteer automation for measurement

See references/typescript-advanced.md for:

  • TypeScript lazyLoad utility
  • TypeScript image component
  • Advanced service worker with offline fallback
  • TerserPlugin configuration
  • Complete PerformanceMetrics interface

Tools

  • Lighthouse / PageSpeed Insights
  • WebPageTest
  • Chrome DevTools Performance tab
  • web-vitals npm package

Resources

When not to use it

  • When the application is already optimized
  • When performance metrics are within target ranges

Limitations

  • Requires manual implementation of strategies
  • Performance targets vary by project

How it compares

It provides a structured checklist and specific configuration patterns rather than generic advice.

Compared to similar skills

web-performance-optimization side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
web-performance-optimization (this skill)04moReviewIntermediate
nextjs-developer3282moNo flagsAdvanced
frontend-developer274moNo flagsIntermediate
nextjs-app-router-patterns32moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

nextjs-developer

zenobi-us

Expert Next.js developer mastering Next.js 14+ with App Router and full-stack features. Specializes in server components, server actions, performance optimization, and production deployment with focus on building fast, SEO-friendly applications.

328531

frontend-developer

sickn33

Build React components, implement responsive layouts, and handle client-side state management. Masters React 19, Next.js 15, and modern frontend architecture. Optimizes performance and ensures accessibility. Use PROACTIVELY when creating UI components or fixing frontend issues.

2782

nextjs-app-router-patterns

wshobson

Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js applications, implementing SSR/SSG, or optimizing React Server Components.

347

bundle-dynamic-imports

TheOrcDev

Use next/dynamic for lazy-loading heavy components. Apply when importing large components like editors, charts, or rich text editors that aren't needed on initial render.

13

moai-domain-frontend

modu-ai

Frontend development specialist covering React 19, Next.js 16, Vue 3.5, and modern UI/UX patterns with component architecture. Use when building web UIs, implementing components, optimizing frontend performance, or integrating state management.

13

bundle-barrel-imports

TheOrcDev

Import directly from source files instead of barrel files. Apply when using libraries like lucide-react, @mui/material, or @radix-ui/react-* to reduce bundle size and improve dev boot time.

11

Search skills

Search the agent skills registry