How I achieved high performance scores on Page Speed Insights through code splitting, CSS optimization, and smart SSR
Saad Batwa
Apr 15, 2024
After days of optimizing my React web app, I finally achieved what every developer dreams of: 97 Performance, 100 Accessibility, 100 Best Practices, and 100 SEO on Page Speed Insights! Here’s how I did it.
My initial React app had decent functionality but poor performance metrics:
Initially, I used React’s built-in React.lazy() for code splitting. While this improved initial load time, it made the user experience feel like a traditional multi-page website.
I switched to @loadable/component, which offers powerful prefetching and preloading capabilities while maintaining smooth SPA transitions.
Loading large CSS files blocks rendering. My stylesheet was 180KB.
I extracted critical CSS (the styles needed for above-the-fold content) and inlined it, then deferred the rest of the CSS.
When sharing links on WhatsApp, Twitter, or Facebook, they would show generic titles and no preview images. Why? Social media crawlers only fetch the HTML—they don’t execute JavaScript!
I wrapped my React app with ASP.NET Core and implemented dynamic meta tag injection.
| Metric | Before | After | Improvement |
|---|---|---|---|
| Performance | 65 | 97 | +32 |
| First Contentful Paint | 3.2s | 1.1s | -66% |
| Largest Contentful Paint | 4.8s | 1.8s | -63% |
| Time to Interactive | 5.1s | 2.2s | -57% |
| Total Bundle Size | 850KB | 320KB | -62% |
Optimizing a React app to achieve high performance scores isn’t just about following a checklist. It requires understanding how browsers work, how users interact with your site, and making thoughtful trade-offs.
The effort is worth it—not just for the scores, but for the real improvement in user experience!
© 2025, All Rights Reserved.