performance

Performance - Web Optimization

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "performance" with this command: npx skills add dsantiagomj/dsmj-ai-toolkit/dsantiagomj-dsmj-ai-toolkit-performance

Performance - Web Optimization

Build fast, responsive web experiences

When to Use This Skill

Use this skill when:

  • Optimizing Core Web Vitals (LCP, INP, CLS)

  • Implementing code splitting and lazy loading

  • Optimizing images and assets

  • Setting up caching strategies

  • Monitoring performance metrics

Critical Patterns

Pattern 1: Optimize LCP

When: Improving largest contentful paint

Good:

<!-- Prioritize LCP image --> <img src="/hero.jpg" fetchpriority="high" loading="eager" />

<!-- Preload critical resources --> <link rel="preload" href="/hero.jpg" as="image" />

// Next.js optimization <Image src="/hero.jpg" width={1200} height={600} priority />

Target: < 2.5 seconds

Pattern 2: Reduce INP

When: Improving interaction responsiveness

Good:

// Break up long tasks function processChunk(data, index = 0) { if (index >= data.length) return;

processItem(data[index]); setTimeout(() => processChunk(data, index + 1), 0); }

// Debounce expensive operations const handleSearch = debounce((query) => { fetchResults(query); }, 300);

Target: < 200ms

Pattern 3: Prevent CLS

When: Ensuring visual stability

Good:

<!-- Always specify dimensions --> <img src="/image.jpg" width="800" height="600" />

<!-- Reserve space for dynamic content --> <div style="min-height: 250px;"> <!-- Ad or dynamic content --> </div>

// Show skeleton while loading if (isLoading) { return <div className="skeleton" style={{ height: '300px' }} />; }

Target: < 0.1

Pattern 4: Code Splitting

When: Reducing initial bundle size

Good:

// Dynamic imports const HeavyComponent = lazy(() => import('./HeavyComponent'));

function App() { return ( <Suspense fallback={<div>Loading...</div>}> {showChart && <HeavyComponent />} </Suspense> ); }

Why: Load code only when needed, reducing initial load time.

Pattern 5: Image Optimization

When: Optimizing images

Good:

<!-- Modern formats with fallbacks --> <picture> <source srcset="/image.avif" type="image/avif" /> <source srcset="/image.webp" type="image/webp" /> <img src="/image.jpg" alt="Description" /> </picture>

<!-- Lazy loading --> <img src="/image.jpg" loading="lazy" width="800" height="600" />

Why: Modern formats are 30-50% smaller than JPEG.

Code Examples

Example 1: Code Splitting with Dynamic Imports

import { lazy, Suspense } from 'react';

// Lazy load heavy components const ChartComponent = lazy(() => import('./ChartComponent')); const AnalyticsDashboard = lazy(() => import('./AnalyticsDashboard'));

export default function Dashboard() { const [showAnalytics, setShowAnalytics] = useState(false);

return ( <div> <h1>Dashboard</h1>

  &#x3C;Suspense fallback={&#x3C;div>Loading chart...&#x3C;/div>}>
    &#x3C;ChartComponent />
  &#x3C;/Suspense>

  &#x3C;button onClick={() => setShowAnalytics(true)}>
    Show Analytics
  &#x3C;/button>

  {showAnalytics &#x26;&#x26; (
    &#x3C;Suspense fallback={&#x3C;div>Loading analytics...&#x3C;/div>}>
      &#x3C;AnalyticsDashboard />
    &#x3C;/Suspense>
  )}
&#x3C;/div>

); }

Example 2: Optimized Image Loading

import Image from 'next/image';

export function HeroSection() { return ( <section> {/* LCP image - prioritize loading */} <Image src="/hero-banner.jpg" width={1200} height={600} priority alt="Hero banner" />

  {/* Below-the-fold images - lazy load */}
  &#x3C;div className="grid grid-cols-3 gap-4 mt-8">
    {products.map(product => (
      &#x3C;Image
        key={product.id}
        src={product.image}
        width={400}
        height={300}
        loading="lazy"
        alt={product.name}
      />
    ))}
  &#x3C;/div>
&#x3C;/section>

); }

For comprehensive examples and detailed implementations, see the references/ folder.

Quick Checklist

Images:

  • ✅ Use WebP/AVIF with fallbacks

  • ✅ Lazy load below-the-fold images

  • ✅ Specify width and height

  • ✅ Set fetchpriority="high" on LCP image

JavaScript:

  • ✅ Code split by route

  • ✅ Lazy load heavy components

  • ✅ Tree shake unused code

  • ✅ Defer non-critical scripts

Caching:

  • ✅ Set Cache-Control headers

  • ✅ Use CDN for static assets

  • ✅ Implement service worker

Progressive Disclosure

For detailed implementations:

  • Core Web Vitals - LCP, INP, CLS optimization strategies

  • Optimization Techniques - Code splitting, image optimization, caching

References

  • Core Web Vitals

  • Optimization Techniques

  • Web.dev Performance

  • Core Web Vitals Guide

Maintained by dsmj-ai-toolkit

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

vercel-ai-sdk

No summary provided by upstream source.

Repository SourceNeeds Review
General

caching

No summary provided by upstream source.

Repository SourceNeeds Review
General

zustand

No summary provided by upstream source.

Repository SourceNeeds Review