
7 Next.js Performance Optimizations That Took Our Site from 55 to 94 on PageSpeed
Last month, our agency website scored 55 on Google PageSpeed Insights (mobile). Today, it scores 94 on desktop and 78 on mobile — and we're still pushing higher. Here are the 7 changes that made the biggest difference, with actual code you can copy into your Next.js project today. 1. Lazy Load Third-Party Scripts (GTM, Analytics, Chat Widgets) This single change gave us the biggest performance jump. Google Tag Manager alone was loading 250KB of JavaScript on page load — most of it unused. Before: GTM loads immediately, blocking the main thread. // layout.tsx — DON'T do this import { GoogleTagManager , GoogleAnalytics } from ' @next/third-parties/google ' export default function Layout ({ children }) { return ( < html > < GoogleTagManager gtmId = "GTM-XXXXX" /> < body > { children } </ body > < GoogleAnalytics gaId = "G-XXXXX" /> </ html > ) } After: GTM loads 3 seconds after page load or on first user interaction — whichever comes first. // components/Analytics.tsx ' use client ' impor
Continue reading on Dev.to Webdev
Opens in a new tab


