How I Optimized a Next.js Website From a 5.2s LCP to 1.1s (A Real Case Study)
Kowshik Valipireddy
Full Stack & React Native Mobile Engineer
While building and scaling production web applications, auditing on mobile 4G network throttling revealed painful metrics: Largest Contentful Paint (LCP) was clocking in at 5.2 seconds, Time to First Byte (TTFB) was sluggish, and the Lighthouse performance score was hovering around 48/100.
1. The Starting Point: A Sluggish 5.2s LCP
Google considers any LCP over 2.5 seconds to be "Poor". A slow LCP suppresses SEO rankings and increases bounce rates by up to 60%. Here is what the initial audit revealed:
- Unoptimized hero images: A 2.4MB PNG hero background was loading via standard CSS
background-imagewithout responsive resizing or priority preloading. - Heavy third-party and client bundles: Animation libraries and charting modules were imported statically in top-level layout components, bloating the initial JS bundle to over 680KB.
- Render-blocking external fonts: Unhosted web fonts were blocking text paint for over 800ms while waiting for Google Fonts CDN responses.
2. Profiling & Diagnosing Root Causes
Using the Chrome DevTools Performance tab and Lighthouse under a simulated Fast 4G / 4x CPU slowdown, we isolated the exact render timeline. The hero image was being discovered late in the network waterfall because the browser had to first download, parse, and execute the CSS stylesheet before requesting the image.
3. Fix 1: Next/Image & Priority AVIF Assets
We replaced the background CSS image with Next.js <Image /> using the priority attribute and configured Next.js image optimization in next.config.ts for AVIF and WebP:
// next.config.ts
const nextConfig = {
images: {
formats: ['image/avif', 'image/webp'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
},
};
Adding priority injects a high-priority <link rel="preload" as="image"> tag directly in the server-rendered HTML <head>, allowing the browser to fetch the hero asset before any JavaScript finishes parsing.
4. Fix 2: Dynamic Imports & Pruning Client JS
Offload non-critical client widgets (such as particle canvases or below-the-fold modals) using next/dynamic with ssr: false:
import dynamic from 'next/dynamic';
const ParticleBackground = dynamic(
() => import('@/components/ParticleBackground'),
{ ssr: false }
);
This cut our initial main-thread JavaScript bundle by 42% (from 680KB to 395KB), freeing up the CPU to render DOM nodes instantly.
5. Fix 3: Zero-Layout-Shift Web Fonts
We migrated from external @import CSS font links to Next.js next/font/google. Next.js automatically downloads the font files at build time and hosts them locally alongside static assets with automatic size-adjust fallbacks, eliminating Cumulative Layout Shift (CLS) and FOIT (Flash of Invisible Text).
6. The Results: From 5.2s to 1.1s
BEFORE OPTIMIZATION
LCP: 5.2s
TTFB: 1.2s
CLS: 0.18
Lighthouse Score: 48/100
AFTER OPTIMIZATION
LCP: 1.1s (78% faster)
TTFB: 180ms
CLS: 0.001
Lighthouse Score: 99/100
HealthTrack Analytics — High Performance Web Platform
See how sub-second data queries, optimized image pipelines, and responsive rendering were engineered into the live HealthTrack platform.
Related Topics & Technologies
Kowshik Valipireddy
AuthorFull Stack & React Native Mobile Engineer
Full Stack Developer & React Native Mobile Engineer specializing in React, Next.js, React Native (iOS & Android), TypeScript, Node.js, and AI workflows. Building fast, accessible, and high-performance cross-platform applications.
Recommended Articles
View allNext.js SEO: Complete Guide to Dynamic Metadata, Sitemaps & Structured Data
A comprehensive engineering guide to implementing dynamic metadata, automated XML sitemaps, robots.txt, and Schema.org JSON-LD structured data in Next.js App Router.
Building Antique Journal: Zero-Knowledge AI Semantic Memory & Tactile Editorial Canvas
Engineering a tactile digital sanctuary: marrying nostalgic paper typography with high-speed client-side vector embeddings, emotional chronometer state, and zero-knowledge encryption.
Full-Stack & Mobile Developer Roadmap 2026: From Fundamentals to Production Cloud
The ultimate 2026 Full-Stack & Mobile Engineering Roadmap: mastering modern TypeScript, Next.js App Router, React Native Expo, relational databases, AI tool calling, and DevOps pipelines.