All jobs / Frontend / web developer / Performance
Frontend / web developer interview question · 0–1 years
Images pop the page down as they load. What do you set and why?
The strongest answer
Set width and height (or aspect-ratio) so the browser reserves space; keep max-width: 100% so they still shrink
Why it works
Reserved aspect ratio is the CLS fix. HTML width/height plus CSS is the usual pattern.
What a good answer covers
- Reserve space before the bytes arrive.
- Width/height or aspect-ratio on the image.
- Fluid CSS so it still fits small screens.
- Don't gate the whole page on images.
Answers that fall short
- Close, but not the strongest: Guess a min-height on a wrapper
A guessed min-height helps until the real ratio is different. - Weak: Wait for onLoad and fade in with no reserved space
Fading in without space still shifts the page. - Red flag: Hide the whole page until every image has loaded
Blocking first paint on images punishes LCP for no reason.
Who gets asked this
More Performance questions
- The main bundle includes an admin charts page most visitors never open. What do you do?
- When would you render a marketing homepage on the server versus a settings screen on the client?
- A late-loading banner pushes content down (CLS). How do you prevent it?
- LCP is a hero image. What do you change first?
- Clicking Filter freezes the tab for about 400ms. How do you investigate?
- Product asks if the new home is faster. What do you report?
- How do you ingest Web Vitals without drowning the backend or leaking PII?
- How do you keep marketing JS from growing without anyone noticing?