Slides: https://tkmaxx-workshop-optimization.vercel.app/optimization
Welcome to ACME's performance optimization workshop! Learn to identify and fix common performance issues in Next.js applications.
- Node.js 18+ installed
- Basic knowledge of Next.js App Router
- Understanding of React Server Components
# Install dependencies
npm install
# Run development server
npm run dev
# Visit http://localhost:3000The Portfolio application is intentionally unoptimized with these issues:
- Uses
<img>tags instead ofnext/image - Loads Google Fonts via
<link>tag instead ofnext/font - Sequential data fetches on homepage (waterfall)
- Entire projects page is
'use client'withuseEffect - Barrel imports (
components/index.ts) prevent tree-shaking - Heavy Chart component statically imported (not code-split)
- No metadata or SEO optimization
- No
remotePatternsconfigured for images
Replace all <img> tags with next/image:
- Add
priorityto the hero image (LCP candidate) - Set proper
sizesattribute for responsive images - Configure
remotePatternsinnext.config.tsfor picsum.photos and avatars.githubusercontent.com
Remove the <link> Google Fonts tag from the layout:
- Use
next/font/googleto load Inter - Configure
subsets,display: 'swap', andvariable - Apply the font via CSS variable
The homepage fetches data sequentially (250ms + 500ms + 300ms = 1050ms):
- Use
Promise.all()to fetch in parallel - Or wrap sections in
<Suspense>for streaming
The projects page is entirely 'use client':
- Convert the page itself to a Server Component
- Only keep
ProjectFilteras a Client Component - Fetch data on the server instead of via API route
Add proper metadata:
- Static
metadataexport inlayout.tsx(title, description) generateMetadatain project detail page- Create
sitemap.tsat app root
Fix barrel imports and code splitting:
- Replace
import { X } from "@/components"with direct imports - Use
next/dynamicto lazy-load the Chart component on the contact page
Add loading.tsx and Suspense boundaries for a polished loading experience.
Audit the navigation links instead of forcing every one to prefetch. Keep the
default for Home and Projects, then compare it with prefetch={true} on one
representative project-detail link in a production run. Do not add it to every
card in the grid.
- Image Optimization
- Font Optimization
- Lazy Loading
- Metadata
- Bundle Analyzer
- Next.js 16.3
- Instant Navigations
Happy coding!