Intermediatenote 02 of 0803 reasons · 03 notes
PerformanceIntermediate
Preload only the critical asset
Preload the hero image or primary font, but avoid turning preload into another bottleneck.
Code example
Copy, adapt, and ship.
Read the numbered lines, copy the complete snippet, then adjust the values for your project.
<link rel="preload" as="image" href="/images/home-hero.webp" imagesrcset="/images/home-hero.webp 1x, /images/home-hero@2x.webp 2x" imagesizes="100vw"/>Why this matters
The production reason.
- 01
Preload tells the browser an asset is important before normal discovery would find it.
- 02
Use it for one true critical asset, such as a hero image or primary font file. Too many preloads compete with each other.
- 03
Wrong preloads can make performance worse by stealing bandwidth from CSS or route JavaScript.
How it holds up outside a demo.
- Next.jsUse priority on the hero Image instead of manual preload in most cases.
- FontsPreload only the primary above-the-fold font weight.
- Performance auditsRemove preloads that are not used immediately.
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