">
 

I Audited the Icon System of 12 Side Projects - Here's the Pattern That Kept Breaking Performance

Iniciado por joomlamz, Hoje at 06:25

Respostas: 0   |   Visualizações: 1

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

I Audited the Icon System of 12 Side Projects - Here's the Pattern That Kept Breaking Performance



Tópico: I Audited the Icon System of 12 Side Projects - Here's the Pattern That Kept Breaking Performance
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
A few weeks back I went down a rabbit hole: I pulled up twelve random open-source frontend repos (mostly dashboards and SaaS landing pages) and looked at exactly how each one was shipping its icons. Not the design — the delivery mechanism. Inline SVG? Icon font? Sprite sheet? Base64?

What I found was almost depressingly consistent. Nine out of twelve repos had some version of the same problem, and it wasn't the one most performance checklists warn you about.

The usual suspects everyone already knows about

Most devs have internalized these by now:

Icon fonts (Font Awesome-style) pulling in a 200KB font file for 40 glyphs actually used

tags pointing at PNG icons that should obviously be vector

No loading="lazy" on decorative icon grids

These are real, but they're also the easy 20% that most tooling already flags. The boring fix is "switch to SVG," and most teams have already done that part.

The problem nobody flags: how the SVG gets into the DOM

Here's what actually showed up nine times out of twelve: teams switched to SVG correctly, then undid the win by how they imported it.

Three patterns kept repeating:

• One giant sprite, every icon, every page. A single icons.svg sprite with 300  definitions, loaded on every route even though any given page used six of them. Browser cache helps after first load, but first paint still pays for it.

• Base64-inlined SVGs in component libraries. Convenient for a quick prototype, brutal for production — base64 inflates payload size by roughly a third over raw SVG, and it can't be cached independently of the JS bundle it's embedded in. Ship a new build, re-download every icon.

• No tree-shaking on icon imports. import * as Icons from 'icon-library' instead of named imports, which silently drags the entire set into the bundle regardless of usage.
None of these show up as "errors." Lighthouse won't fail you. They just quietly tax every page load, forever, until someone audits it by hand — which is what I ended up doing for six hours on a Saturday.
What a cleaner setup actually looks like
The repos that got this right shared three habits:
jsx// Named import — only this icon ships in the bundle
import { ArrowRight } from 'my-icon-set';

function CTAButton() {

return (

Continue

);

}

html<!-- Raw inline SVG for above-the-fold, critical icons -->

css/* For repeated decorative icons, currentColor keeps them themeable

without duplicating markup per color variant */

.icon {

fill: currentColor;

width: 1em;

height: 1em;

}

Small things, but they compound: per-icon imports instead of whole-set imports, raw SVG instead of base64, currentColor instead of baked-in fill values so you're not shipping five copies of the same path for five color states.

Where I actually pulled the test icons from

For the audit I needed a few hundred throwaway icons across different visual styles (outlined, filled, duotone) to simulate realistic bundle sizes without spending a day drawing paths by hand. I ended up using IamVector's free SVG icon library, which has 200,000+ icons covering outline, filled, and multicolor styles — useful here specifically because the icons came as clean, uncompressed SVG markup rather than pre-baked sprite sheets, which made it easy to test each import pattern in isolation.

A couple of things made the testing faster:

The style filters let me grab a consistent outlined set instead of hand-picking icons that didn't visually match — useful when you're trying to isolate "does bundling strategy matter" from "do these icons even look coherent together."

The built-in SVG code editor let me strip unnecessary attributes (IDs, inline styles, editor cruft) straight in the browser before pasting into the test repos, which mattered because uncleaned export artifacts were inflating a few of my "control" measurements.

For one test case I needed PNG fallbacks for an old build pipeline that didn't support SVG imports yet, so I used their SVG-to-PNG converter instead of opening a separate design tool just for that.

If you want to run a similar audit on your own project, grabbing icons from a free SVG icon library that exposes raw markup (rather than locking icons behind a font or a paid sprite generator) makes the comparison a lot less painful.

The actual takeaway

If you've already "switched to SVG" and consider the icon problem solved, it's worth spending fifteen minutes checking how those SVGs enter your bundle. The format was never really the bottleneck — the import pattern is. Of the nine repos with this issue, fixing just the import pattern (no other changes) dropped first-load JS by 8–22KB gzipped, which isn't huge, but it's also completely free once you know to look for it.

Curious if others are seeing the same pattern — what's your team's icon import setup look like, sprite, inline, or per-component?


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: