Beginnernote 04 of 0803 reasons · 03 notes
PerformanceBeginner
Reserve media dimensions
Use width, height, or aspect-ratio so images and embeds do not create layout shifts.
Code example
Copy, adapt, and ship.
Read the numbered lines, copy the complete snippet, then adjust the values for your project.
<img src="/case-study.jpg" alt="Dashboard case study" width="1200" height="675" loading="lazy"/>Why this matters
The production reason.
- 01
Images and embeds without reserved dimensions cause content to jump after loading.
- 02
That layout shift hurts reading comfort and can affect Core Web Vitals.
- 03
Reserve dimensions with width and height attributes, aspect-ratio CSS, or framework image components.
How it holds up outside a demo.
- HTMLWidth and height attributes let browsers calculate aspect ratio early.
- Next.jsImage enforces dimensions unless using fill, where the parent must reserve space.
- EmbedsWrap videos and maps in an aspect-ratio container.
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