Advancednote 03 of 0803 reasons · 03 notes
PerformanceAdvanced
Measure route-level bundles
Find heavy dependencies imported into shared layout code before chasing tiny wins.
Code example
Copy, adapt, and ship.
Read the numbered lines, copy the complete snippet, then adjust the values for your project.
import dynamic from "next/dynamic"; const ChartPanel = dynamic(() => import("./ChartPanel"), { ssr: false, loading: () => <p>Loading chart...</p>,});Why this matters
The production reason.
- 01
A heavy dependency imported into a shared layout can silently affect every page.
- 02
Measure bundles per route before optimizing tiny components. One charting library or editor can outweigh dozens of small UI files.
- 03
Move heavy code into dynamic imports or route-specific components when it is not needed globally.
How it holds up outside a demo.
- Next.jsUse @next/bundle-analyzer for route-level visibility.
- React dashboardsDynamically import charts, editors, and maps.
- Marketing sitesKeep animation libraries out of the global layout if only one page needs them.
Explore other stacks
Jump into a different technology.
08 Performance notes on this shelf, and six more stacks beside it.
Use next/image for image optimization
Next.js image optimization starts with next/image sizing, lazy loading, modern formats, and predictable dimensions.
Open the noteKeep state close to the interaction
Local state avoids unnecessary parent renders and keeps component intent obvious.
Open the noteAbort stale fetch requests
Cancel outdated browser requests so fast UI changes do not render old data.
Open the noteBuild a CSS gradient generator with code export
A CSS gradient generator should preview color stops, preserve accessible contrast, and export clean CSS code.
Open the noteFix WordPress H1 SEO issues
Fix WordPress SEO issues by keeping one clear H1, escaping template output, and compressing images before WordPress upload.
Open the noteUse real buttons for actions
If it changes state, use button. If it navigates, use a link.
Open the note