Back to Blog
Frontend

React Performance Optimization: From 4s to 1.2s Load Time

Learn how I optimized a React application from 4 seconds to 1.2 seconds initial load time using code splitting, lazy loading, and strategic memoization.

Sanjay ThakurMay 7, 20268 min read
React Performance Optimization: From 4s to 1.2s Load Time

The Challenge

When I took over the Trading Management System project, the initial page load was painfully slow at 4+ seconds. Users complained about poor responsiveness, and the Lighthouse performance score was stuck at 32.

The Investigation

Using Chrome DevTools and Lighthouse, I identified several bottlenecks:

  • Large JavaScript bundle (450KB)
  • Unnecessary re-renders across component tree
  • Unoptimized images and third-party scripts
  • Missing code splitting

The Solution

1. Code Splitting with Dynamic Imports

const ProjectCarousel = dynamic(() => import('@/components/ProjectCarousel'), {
  loading: () => <p>Loading...</p>,
  ssr: false
})

2. Strategic Memoization

const KeySkills = memo(() => {
  return <div>Skills...</div>
})

3. Image Optimization

Used Next.js Image component with blur placeholders and WebP format.

4. Bundle Analysis

Removed unused dependencies and optimized tree-shaking.

Results

  • Initial Load Time: 4s → 1.2s (70% improvement)
  • Lighthouse Performance: 32 → 89
  • First Contentful Paint: 2.8s → 0.9s
  • Cumulative Layout Shift: 0.15 → 0.02

Key Takeaways

  1. Always profile before optimizing
  2. Code splitting is your friend for large apps
  3. Image optimization can provide 30-40% improvements
  4. Monitor bundle size in CI/CD

Resources

ReactPerformanceOptimizationWeb Development