Web Performance Optimization
Performance January 10, 2024 · 10 min read

Web Performance Optimization

Miloš

Miloš Knežević

Full Stack Developer

Achieving a perfect Lighthouse score isn't just about bragging rights — it directly impacts user experience, SEO rankings, and conversion rates. Here's exactly how I optimized an enterprise application to score 100/100 across all metrics.

The Starting Point

The application was a React-based e-commerce platform with 200+ product pages. Initial Lighthouse scores were: Performance 34, Accessibility 78, Best Practices 82, SEO 71. Load time on mobile was over 8 seconds.

Step 1: Image Optimization

Images were the biggest offender, accounting for 4.2MB of the total 5.8MB page weight. I implemented:

// Next.js Image component with WebP + AVIF
<Image 
  src="/product.jpg"
  alt="Product photo"
  width={800} height={600}
  placeholder="blur"
  blurDataURL={shimmer(800, 600)}
  sizes="(max-width: 768px) 100vw, 50vw"
/>

This alone reduced image payload by 73% through automatic format selection, lazy loading, and responsive sizing.

Step 2: Code Splitting & Tree Shaking

The JavaScript bundle was 1.8MB. Using dynamic imports and analyzing the bundle with webpack-bundle-analyzer, I identified that 60% of the code was unused on initial load. After aggressive code splitting:

// Before: 1.8MB single bundle
import { FullCalendar } from 'calendar-lib';

// After: 340KB initial + lazy loaded chunks
const FullCalendar = dynamic(
  () => import('calendar-lib'), 
  { loading: () => <CalendarSkeleton /> }
);

Step 3: Critical CSS & Font Loading

I extracted critical above-the-fold CSS and inlined it, deferring the rest. Fonts were preloaded with font-display: swap to eliminate render-blocking resources.

Results

After two weeks of optimization: Performance 100, Accessibility 100, Best Practices 100, SEO 100. Mobile load time dropped from 8.2s to 1.1s. The client saw a 25% increase in conversions within the first month.