Next.js 15 Speed Hacks: 7 Tweaks for a Perfect Lighthouse Score
Understanding Core Web Vitals in 2025
Largest Contentful Paint (LCP)
Interaction to Next Paint (INP)
Cumulative Layout Shift (CLS)
Hack 1: Embrace the Power of Turbopack
Enabling Turbopack for Development
How Turbopack Accelerates Development
Hack 2: Master the Next.js Image Component
Automatic Optimization and Modern Formats
Using the 'priority' Prop for LCP Elements
Preventing CLS with Static Dimensions
Hack 3: Optimize Font Loading
Self-Hosting Fonts with next/font
Leveraging font-display: swap
Hack 4: Implement Intelligent Code Splitting
Dynamic Imports for Components
Disabling SSR for Client-Side Only Components
Hack 5: Refined Caching Strategies
Understanding the New Caching Semantics
On-Demand and Time-Based Revalidation
Hack 6: Leverage Script Optimization with next/script
Choosing the Right Loading Strategy
Moving Scripts to the Worker Thread
Hack 7: Monitor and Analyze with Vercel Analytics
Setting Up Vercel Analytics
Interpreting Your Performance Score
Conclusion
References
package.json
, update your dev script:next.config.js
:sizes
prop is crucial for responsive images. It tells the browser which image size to download based on the viewport width, preventing mobile devices from downloading desktop-sized images.priority
prop. This tells Next.js to preload the image, ensuring it loads as quickly as possible:fill
prop with a container that has relative positioning. This maintains aspect ratio while preventing shifts.next/font
module solves these problems elegantly.next/font
is straightforward. Here's how to implement Google Fonts:font-display: swap
font-display: swap
CSS property is automatically applied by next/font
, ensuring text remains visible during font load. This prevents the dreaded invisible text problem that hurts user experience.window
, document
, or other browser-specific APIs. It prevents hydration mismatches and reduces the server-side bundle size.fetch
requests and GET Route Handlers are no longer cached by default. This breaking change prevents unexpected stale data issues but requires you to be more intentional about caching:revalidateTag
for on-demand updates:next/script
component gives you fine-grained control over when and how these scripts load.beforeInteractive
sparingly—only for truly critical scripts. Most analytics and tracking scripts work perfectly with afterInteractive
. Chat widgets and other non-essential features should use lazyOnload
.worker
strategy is a game-changer for script performance. It runs scripts in a web worker, completely freeing up the main thread:Posted Jun 19, 2025
Unlock top performance in Next.js 15. Discover 7 essential speed hacks to optimize your app, satisfy Core Web Vitals, and achieve a green Lighthouse score overnight.