React Performance Optimization Techniques
Performance is crucial for user experience. Here are proven techniques to make your React applications faster and more efficient.
Code Splitting
Break your application into smaller chunks that load on demand. This reduces initial load time significantly — often by 40-60% for large applications.
const Dashboard = React.lazy(() => import('./Dashboard'));
const Reports = React.lazy(() => import('./Reports'));Wrap lazy components with Suspense and a loading fallback for a smooth user experience.
Memoization with useMemo and useCallback
Prevent unnecessary re-renders by memoizing expensive calculations and stable function references.
- useMemo — caches the result of an expensive computation
- useCallback — caches a function reference to prevent child re-renders
Only memoize when the computation is genuinely expensive or when referential equality matters for child components.
Virtual Scrolling
For long lists with 100+ items, render only the items visible in the viewport. Libraries like TanStack Virtual or react-window reduce DOM nodes by 90%+, dramatically improving scroll performance.
Image Optimisation
- Use modern formats (WebP, AVIF) — 25-50% smaller than JPEG/PNG
- Implement lazy loading with
loading="lazy"or Intersection Observer - Serve correctly-sized images with
srcset - Use a CDN for global fast delivery
Bundle Size Reduction
- Remove unused dependencies with tree shaking
- Analyse your bundle with Webpack Bundle Analyzer or Vite's rollup-plugin-visualizer
- Replace heavy libraries with lightweight alternatives
- Use dynamic imports for infrequently-used features
React.memo for Pure Components
Wrap functional components with React.memo to skip re-renders when props have not changed.
Conclusion
Performance optimisation is an ongoing discipline. Measure first with React DevTools Profiler, then optimise the bottlenecks — never guess.