Icon Rendering — Part 2
SVG sprites, icon fonts, and inline SVG compared in depth.
With the fundamentals down, let's walk the techniques in the order they evolved. The first three are raster-based — each one fixing a pain point of the one before it: separate images → sprites → fonts.
Separate images
The baseline isn't really a “technique” — it's just treating each icon as an ordinary image: one <img> (or background) per icon, each its own file and its own request. It's dead simple and works in every environment, and because each file is cached independently, changing one icon never invalidates the others.
Why many requests hurt
A page with 200 icons fires 200 requests — each with its own handshake and round-trip. That's the wall the next technique tears down:
Image sprite
The image sprite solves the request problem: pack every icon into one big image, download it once, then show just the slice you need by shifting background-position like a window over the sheet. Pick an icon and watch the crop slide:
Mature tooling generates the sheet and the per-icon CSS classes for you, so you never compute offsets by hand. The trade: it's still raster (no scaling, no recolor), and changing one icon regenerates the whole sheet — invalidating its cache for everyone.
Icon fonts
Icon fonts make a leap: stop thinking of icons as images and treat them as text. Each icon is a glyph mapped to a code point; you render it with a class and the browser draws it like a character. Suddenly all the text superpowers apply:
Pick the technique
Match each situation to the raster technique that fits best:
Check your understanding
Explore
On a content-heavy site (a news site, a dashboard):
- Open the Network tab and count image requests for icons.
- Look for one large image that contains many icons — that's a sprite.
- Find an element whose
font-familyis an icon font and read its glyph code point.
- →Separate images: simplest and independently cached, but one request per icon, raster-only, no recolor.
- →Image sprite: one request for all via
background-positioncropping — still raster, and one change re-generates the sheet. - →Icon fonts: icons as text glyphs — scalable, recolorable, tiny — but single-color and prone to FOIT/FOUT.
- →Each technique fixes a flaw of the previous one; the right pick depends on count, stability, and whether you need scaling/recolor.