Lesson 18 of 30
An image gallery prompt tests whether a candidate treats images as a first-class system design concern with real cost — bandwidth, DOM weight, and perceived speed — not just as content that happens to be pictures.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A product page carousel has five images. Which technique does the lesson recommend, and why is virtualization not the relevant tool here?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
The prompt: "Design the frontend architecture for an image-heavy gallery or carousel" — think a photo-sharing app's grid view, or a product page's image carousel. The mechanics of how to optimize a single image (formats, responsive srcset, compression) are already covered in the Web Performance track's image-optimization lesson; this lesson assumes that and focuses on the system-level decisions specific to having many images in one view:
These are two different shapes of the same underlying problem, and a strong answer treats them differently rather than reaching for one universal fix.
The grid. A user scrolling through thousands of photos never needs more than the visible window plus a small buffer rendered as real DOM nodes at once — this is the same virtualization idea the Web Performance track's list-virtualization lesson covers for text-heavy lists, applied here to a grid of images instead of rows of text. Combined with lazy-loading (only fetching the image data for cells actually near the viewport), the two together keep both DOM size and network usage bounded regardless of how many total images exist.
The carousel. A product page's carousel is a much smaller, fixed set of images (five, ten slides), so virtualization isn't the relevant tool here — the interesting decision is prefetching. Since the interaction is nearly always "user taps next," the carousel can eagerly fetch the next slide's image as soon as the current one is shown, so by the time the user actually advances, that image is already sitting in the browser's cache instead of triggering a fresh, visible load. This is a narrower, safer bet than prefetching everything: it costs one extra image's worth of bandwidth per slide shown, not the whole carousel up front.
"Design an image-heavy gallery" tests whether a candidate separates the several distinct costs images introduce at scale — network, decode, and DOM size — into the right individual fixes, rather than offering one vague "optimize the images" answer that doesn't actually name a mechanism.