Skip to main content
While Web Quality Skills are framework-agnostic, each framework provides specialized tools and patterns for implementing performance, accessibility, and SEO optimizations. This guide shows you how to apply skill recommendations in your framework of choice.

Core Web Vitals by Framework

Optimizing LCP (Largest Contentful Paint)

The LCP element is typically a hero image or large text block. Each framework provides optimized image components.
import Image from 'next/image';

export default function Hero() {
  return (
    <Image 
      src="/hero.jpg"
      priority          // Preloads with high priority
      fill              // Fills container
      sizes="100vw"     // Responsive sizing
      alt="Hero image"
    />
  );
}
Key features:
  • Automatic WebP/AVIF generation
  • Built-in lazy loading (disabled with priority)
  • Automatic responsive images via sizes
  • Image optimization at build time

Optimizing INP (Interaction to Next Paint)

INP measures responsiveness. Heavy event handlers and re-renders are common culprits.
import { useState, useTransition, useMemo } from 'react';

function ExpensiveList({ items }) {
  const [filter, setFilter] = useState('');
  const [isPending, startTransition] = useTransition();

  // Defer non-urgent updates
  const handleFilterChange = (e) => {
    startTransition(() => {
      setFilter(e.target.value);
    });
  };

  // Memoize expensive computations
  const filteredItems = useMemo(() => {
    return items.filter(item => 
      item.name.toLowerCase().includes(filter.toLowerCase())
    );
  }, [items, filter]);

  return (
    <>
      <input 
        onChange={handleFilterChange} 
        placeholder="Filter..."
      />
      {isPending && <div>Updating...</div>}
      <List items={filteredItems} />
    </>
  );
}

// Prevent unnecessary re-renders
const List = React.memo(({ items }) => {
  return items.map(item => <Item key={item.id} item={item} />);
});
Key techniques:
  • useTransition for non-urgent updates
  • useMemo for expensive calculations
  • React.memo to prevent re-renders
  • useCallback for stable function references

Optimizing CLS (Cumulative Layout Shift)

Prevent unexpected layout shifts by reserving space for dynamic content.
import Image from 'next/image';

// Image component automatically prevents CLS
<Image 
  src="/photo.jpg" 
  width={800} 
  height={600} 
  alt="Photo" 
/>

// For dynamic content, reserve space
<div style={{ minHeight: '200px' }}>
  {loading ? <Skeleton /> : <Content />}
</div>

// Use CSS aspect-ratio for responsive layouts
<div style={{ aspectRatio: '16/9', width: '100%' }}>
  <iframe src="..." />
</div>

Code Splitting & Lazy Loading

import { lazy, Suspense } from 'react';

// Component-level code splitting
const HeavyComponent = lazy(() => import('./HeavyComponent'));

function App() {
  return (
    <Suspense fallback={<LoadingSpinner />}>
      <HeavyComponent />
    </Suspense>
  );
}

// Route-based splitting
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Profile = lazy(() => import('./pages/Profile'));

Error Handling

class ErrorBoundary extends React.Component {
  state = { hasError: false };
  
  static getDerivedStateFromError(error) {
    return { hasError: true };
  }
  
  componentDidCatch(error, info) {
    // Log to error tracking service
    console.error('Error:', error, info);
  }
  
  render() {
    if (this.state.hasError) {
      return <ErrorFallback />;
    }
    return this.props.children;
  }
}

// Usage
<ErrorBoundary>
  <App />
</ErrorBoundary>

SEO & Meta Tags

import Head from 'next/head';

export default function Page() {
  return (
    <>
      <Head>
        <title>Page Title - Site Name</title>
        <meta 
          name="description" 
          content="Compelling page description" 
        />
        <meta property="og:title" content="Page Title" />
        <meta property="og:description" content="..." />
        <link rel="canonical" href="https://example.com/page" />
      </Head>
      <main>{/* Content */}</main>
    </>
  );
}

// Or use Next.js 13+ Metadata API
export const metadata = {
  title: 'Page Title',
  description: 'Page description',
};

Core Web Vitals

Deep dive into LCP, INP, and CLS optimization

Performance

Comprehensive performance optimization guide

Build docs developers (and LLMs) love