performance

Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".

7 stars

Best use case

performance is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".

Teams using performance should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/performance/SKILL.md --create-dirs "https://raw.githubusercontent.com/RodrigoTomeES/getmcp/main/.agents/skills/performance/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/performance/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How performance Compares

Feature / AgentperformanceStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Performance optimization

Deep performance optimization based on Lighthouse performance audits. Focuses on loading speed, runtime efficiency, and resource optimization.

## How it works

1. Identify performance bottlenecks in code and assets
2. Prioritize by impact on Core Web Vitals
3. Provide specific optimizations with code examples
4. Measure improvement with before/after metrics

## Performance budget

| Resource                | Budget   | Rationale                |
| ----------------------- | -------- | ------------------------ |
| Total page weight       | < 1.5 MB | 3G loads in ~4s          |
| JavaScript (compressed) | < 300 KB | Parsing + execution time |
| CSS (compressed)        | < 100 KB | Render blocking          |
| Images (above-fold)     | < 500 KB | LCP impact               |
| Fonts                   | < 100 KB | FOIT/FOUT prevention     |
| Third-party             | < 200 KB | Uncontrolled latency     |

## Critical rendering path

### Server response

- **TTFB < 800ms.** Time to First Byte should be fast. Use CDN, caching, and efficient backends.
- **Enable compression.** Gzip or Brotli for text assets. Brotli preferred (15-20% smaller).
- **HTTP/2 or HTTP/3.** Multiplexing reduces connection overhead.
- **Edge caching.** Cache HTML at CDN edge when possible.

### Resource loading

**Preconnect to required origins:**

```html
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://cdn.example.com" crossorigin />
```

**Preload critical resources:**

```html
<!-- LCP image -->
<link rel="preload" href="/hero.webp" as="image" fetchpriority="high" />

<!-- Critical font -->
<link rel="preload" href="/font.woff2" as="font" type="font/woff2" crossorigin />
```

**Defer non-critical CSS:**

```html
<!-- Critical CSS inlined -->
<style>
  /* Above-fold styles */
</style>

<!-- Non-critical CSS -->
<link rel="preload" href="/styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'" />
<noscript><link rel="stylesheet" href="/styles.css" /></noscript>
```

### JavaScript optimization

**Defer non-essential scripts:**

```html
<!-- Parser-blocking (avoid) -->
<script src="/critical.js"></script>

<!-- Deferred (preferred) -->
<script defer src="/app.js"></script>

<!-- Async (for independent scripts) -->
<script async src="/analytics.js"></script>

<!-- Module (deferred by default) -->
<script type="module" src="/app.mjs"></script>
```

**Code splitting patterns:**

```javascript
// Route-based splitting
const Dashboard = lazy(() => import("./Dashboard"));

// Component-based splitting
const HeavyChart = lazy(() => import("./HeavyChart"));

// Feature-based splitting
if (user.isPremium) {
  const PremiumFeatures = await import("./PremiumFeatures");
}
```

**Tree shaking best practices:**

```javascript
// ❌ Imports entire library
import _ from "lodash";
_.debounce(fn, 300);

// ✅ Imports only what's needed
import debounce from "lodash/debounce";
debounce(fn, 300);
```

## Image optimization

### Format selection

| Format | Use case                    | Browser support |
| ------ | --------------------------- | --------------- |
| AVIF   | Photos, best compression    | 92%+            |
| WebP   | Photos, good fallback       | 97%+            |
| PNG    | Graphics with transparency  | Universal       |
| SVG    | Icons, logos, illustrations | Universal       |

### Responsive images

```html
<picture>
  <!-- AVIF for modern browsers -->
  <source
    type="image/avif"
    srcset="hero-400.avif 400w, hero-800.avif 800w, hero-1200.avif 1200w"
    sizes="(max-width: 600px) 100vw, 50vw"
  />

  <!-- WebP fallback -->
  <source
    type="image/webp"
    srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
    sizes="(max-width: 600px) 100vw, 50vw"
  />

  <!-- JPEG fallback -->
  <img
    src="hero-800.jpg"
    srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w"
    sizes="(max-width: 600px) 100vw, 50vw"
    width="1200"
    height="600"
    alt="Hero image"
    loading="lazy"
    decoding="async"
  />
</picture>
```

### LCP image priority

```html
<!-- Above-fold LCP image: eager loading, high priority -->
<img src="hero.webp" fetchpriority="high" loading="eager" decoding="sync" alt="Hero" />

<!-- Below-fold images: lazy loading -->
<img src="product.webp" loading="lazy" decoding="async" alt="Product" />
```

## Font optimization

### Loading strategy

```css
/* System font stack as fallback */
body {
  font-family:
    "Custom Font",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

/* Prevent invisible text */
@font-face {
  font-family: "Custom Font";
  src: url("/fonts/custom.woff2") format("woff2");
  font-display: swap; /* or optional for non-critical */
  font-weight: 400;
  font-style: normal;
  unicode-range: U+0000-00FF; /* Subset to Latin */
}
```

### Preloading critical fonts

```html
<link rel="preload" href="/fonts/heading.woff2" as="font" type="font/woff2" crossorigin />
```

### Variable fonts

```css
/* One file instead of multiple weights */
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
```

## Caching strategy

### Cache-Control headers

```
# HTML (short or no cache)
Cache-Control: no-cache, must-revalidate

# Static assets with hash (immutable)
Cache-Control: public, max-age=31536000, immutable

# Static assets without hash
Cache-Control: public, max-age=86400, stale-while-revalidate=604800

# API responses
Cache-Control: private, max-age=0, must-revalidate
```

### Service worker caching

```javascript
// Cache-first for static assets
self.addEventListener("fetch", (event) => {
  if (
    event.request.destination === "image" ||
    event.request.destination === "style" ||
    event.request.destination === "script"
  ) {
    event.respondWith(
      caches.match(event.request).then((cached) => {
        return (
          cached ||
          fetch(event.request).then((response) => {
            const clone = response.clone();
            caches.open("static-v1").then((cache) => cache.put(event.request, clone));
            return response;
          })
        );
      }),
    );
  }
});
```

## Runtime performance

### Avoid layout thrashing

```javascript
// ❌ Forces multiple reflows
elements.forEach((el) => {
  const height = el.offsetHeight; // Read
  el.style.height = height + 10 + "px"; // Write
});

// ✅ Batch reads, then batch writes
const heights = elements.map((el) => el.offsetHeight); // All reads
elements.forEach((el, i) => {
  el.style.height = heights[i] + 10 + "px"; // All writes
});
```

### Debounce expensive operations

```javascript
function debounce(fn, delay) {
  let timeout;
  return (...args) => {
    clearTimeout(timeout);
    timeout = setTimeout(() => fn(...args), delay);
  };
}

// Debounce scroll/resize handlers
window.addEventListener("scroll", debounce(handleScroll, 100));
```

### Use requestAnimationFrame

```javascript
// ❌ May cause jank
setInterval(animate, 16);

// ✅ Synced with display refresh
function animate() {
  // Animation logic
  requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
```

### Virtualize long lists

```javascript
// For lists > 100 items, render only visible items
// Use libraries like react-window, vue-virtual-scroller, or native CSS:
.virtual-list {
  content-visibility: auto;
  contain-intrinsic-size: 0 50px; /* Estimated item height */
}
```

## Third-party scripts

### Load strategies

```javascript
// ❌ Blocks main thread
<script src="https://analytics.example.com/script.js"></script>

// ✅ Async loading
<script async src="https://analytics.example.com/script.js"></script>

// ✅ Delay until interaction
<script>
document.addEventListener('DOMContentLoaded', () => {
  const observer = new IntersectionObserver((entries) => {
    if (entries[0].isIntersecting) {
      const script = document.createElement('script');
      script.src = 'https://widget.example.com/embed.js';
      document.body.appendChild(script);
      observer.disconnect();
    }
  });
  observer.observe(document.querySelector('#widget-container'));
});
</script>
```

### Facade pattern

```html
<!-- Show static placeholder until interaction -->
<div class="youtube-facade" data-video-id="abc123" onclick="loadYouTube(this)">
  <img src="/thumbnails/abc123.jpg" alt="Video title" />
  <button aria-label="Play video">▶</button>
</div>
```

## Measurement

### Key metrics

| Metric      | Target  | Tool             |
| ----------- | ------- | ---------------- |
| LCP         | < 2.5s  | Lighthouse, CrUX |
| FCP         | < 1.8s  | Lighthouse       |
| Speed Index | < 3.4s  | Lighthouse       |
| TBT         | < 200ms | Lighthouse       |
| TTI         | < 3.8s  | Lighthouse       |

### Testing commands

```bash
# Lighthouse CLI
npx lighthouse https://example.com --output html --output-path report.html

# Web Vitals library
import {onLCP, onINP, onCLS} from 'web-vitals';
onLCP(console.log);
onINP(console.log);
onCLS(console.log);
```

## References

For Core Web Vitals specific optimizations, see [Core Web Vitals](../core-web-vitals/SKILL.md).

Related Skills

web-quality-audit

7
from RodrigoTomeES/getmcp

Comprehensive web quality audit covering performance, accessibility, SEO, and best practices. Use when asked to "audit my site", "review web quality", "run lighthouse audit", "check page quality", or "optimize my website".

web-design-guidelines

7
from RodrigoTomeES/getmcp

Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

vercel-react-best-practices

7
from RodrigoTomeES/getmcp

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vercel-composition-patterns

7
from RodrigoTomeES/getmcp

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

tailwind-design-system

7
from RodrigoTomeES/getmcp

Build scalable design systems with Tailwind CSS v4, design tokens, component libraries, and responsive patterns. Use when creating component libraries, implementing design systems, or standardizing UI patterns.

seo

7
from RodrigoTomeES/getmcp

Optimize for search engine visibility and ranking. Use when asked to "improve SEO", "optimize for search", "fix meta tags", "add structured data", "sitemap optimization", or "search engine optimization".

react-doctor

7
from RodrigoTomeES/getmcp

Run after making React changes to catch issues early. Use when reviewing code, finishing a feature, or fixing bugs in a React project.

frontend-design

7
from RodrigoTomeES/getmcp

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.

find-skills

7
from RodrigoTomeES/getmcp

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

core-web-vitals

7
from RodrigoTomeES/getmcp

Optimize Core Web Vitals (LCP, INP, CLS) for better page experience and search ranking. Use when asked to "improve Core Web Vitals", "fix LCP", "reduce CLS", "optimize INP", "page experience optimization", or "fix layout shifts".

best-practices

7
from RodrigoTomeES/getmcp

Apply modern web development best practices for security, compatibility, and code quality. Use when asked to "apply best practices", "security audit", "modernize code", "code quality review", or "check for vulnerabilities".

agent-browser

7
from RodrigoTomeES/getmcp

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.