Skip to content

How Much JavaScript Do 50 Icons Add? Five Libraries, Measured

I built the same 50 interface icons with five React icon libraries in Vite 8. Named imports cost 3 to 32 KB gzip; a lookup by name costs far more.

· · 7 min read
Horizontal bars showing gzip bytes added by 50 named icons: Tabler 3.4 KB, Phosphor 31.7 KB

Quick Take

Fifty named icons add between 3.4 KB (Tabler) and 31.7 KB (Phosphor) of gzip JavaScript to a Vite 8 production build, and four of the five libraries land between 3.4 and 5.8 KB. The cost only explodes when icons are looked up by name at runtime: that pulls in the whole package, from 33 KB for Heroicons to 1,050 KB for Phosphor.

Run this yourself. Every number in this article came from react-icon-bundle-cost/ in the Coding Dunia examples repository. npm install && npm run bench rebuilds the full table in about two minutes.

Icons are the one dependency everybody adds without a second thought. A menu needs a chevron, a button needs a trash can, and a package that "tree-shakes" is assumed to cost nothing. I'd believed that for years, and our own Lucide React page even said each icon adds about 1 kB. That turns out to be wrong by a factor of ten.

So I measured it. Same 50 interface concepts, five libraries, one Vite 8 production build.

How Did I Measure the Cost of an Icon?

I picked 50 everyday concepts: home, search, settings, user, bell, mail, calendar and so on up to refresh and save. For each library I looked up the name it uses for that concept, then wrote a small React app that imports exactly the first 1, 10 or 50 of them and renders them. A script builds each app with Vite 8.3.8 and adds up the gzip size (level 9) of every JavaScript file in the output.

The number in the tables is a difference. A baseline app renders the same count of plain <span> elements and ships 67,590 bytes of gzip JavaScript (React 19.3.1 and react-dom), so everything above that line belongs to the icons. Every cell was built three times, and the script stops if the size differs between rounds. It never did.

Versions: lucide-react 1.77.0, react-icons 5.7.0 using its Lucide set, @tabler/icons-react 3.52.0, @phosphor-icons/react 2.1.10, @heroicons/react 2.2.0 from 24/outline. Node 22.23.5 on an M1.

What Do 1, 10 and 50 Named Icons Cost?

Library1 icon10 icons50 icons
@tabler/icons-react395 B1,185 B3,438 B
react-icons (Lucide set)1,217 B2,093 B3,983 B
lucide-react1,458 B2,560 B5,545 B
@heroicons/react (outline)545 B2,236 B5,805 B
@phosphor-icons/react1,176 B10,434 B31,677 B

All values are gzip bytes added on top of the 67,590-byte baseline. Four of the five sit within 2.4 KB of each other at 50 icons. Is that a difference worth choosing a library for? No. Two kilobytes won't show up in any performance report you'll read.

Phosphor is the outlier, and it's the only one where I'd pause.

Why Is the First Icon So Much Dearer Than the Next Forty-Nine?

Look at lucide-react: 1,458 bytes for one icon, 5,545 for fifty. Divide the extra 4,087 bytes by 49 and a further icon costs about 83 bytes. The first one is expensive because it drags in the wrapper component that builds the SVG element, and every later icon reuses it.

The marginal cost per extra icon, after the first, works out like this:

LibraryFirst iconEach extra icon
@tabler/icons-react395 B62 B
react-icons (Lucide set)1,217 B56 B
lucide-react1,458 B83 B
@heroicons/react (outline)545 B107 B
@phosphor-icons/react1,176 B622 B

So "about 1 kB per icon" was a good description of the first icon and a poor one of the other forty-nine. I've corrected the Lucide and react-icons pages to say so.

Why Does Phosphor Cost Ten Times More Per Icon?

I didn't take this on trust, because ten times is a lot. Phosphor ships each icon as a component plus a definition file, and the definition holds every weight the set offers. I opened the House definition in 2.1.10: it contains thin, light, regular, bold, fill and duotone, 2,662 bytes before compression. Render one weight and you still ship six.

That's a design decision, not a bug, and it's what lets you switch weight with a prop. If you use three icons in one weight, you'll never notice. If you build a toolbar of fifty, you've bought roughly 26 KB more than lucide-react would cost, most of it weights nobody sees. In my opinion Phosphor is a fine choice for a small, hand-picked set and a poor default for a design system with a big icon vocabulary.

Does Importing From the Barrel File Bloat a Production Build?

I expected it to, at least for react-icons, whose root package has a reputation. It didn't. All five libraries tree-shook named imports from the package root in Vite 8, and react-icons added fewer bytes at 50 icons than lucide-react did. If you'd read that a barrel import "can bloat" the bundle, that advice describes older bundler setups and dev servers, not a current production build.

I didn't measure the dev server. Vite pre-bundles dependencies there, and first-load behaviour can differ from a build, so treat the table as production only.

One detail turned up while I was matching names. react-icons 5.7.0 still ships the older Lucide name LuFilter, while lucide-react 1.77.0 has Funnel for the same glyph. If you move between the two packages, expect a few renames.

What Happens When You Look Icons Up by Name?

This is where the numbers change by two orders of magnitude. I built a second app per library that imports the whole module and looks up the same 50 icons from a list of strings, the way a menu driven by a CMS or an icon picker works:

Library50 icons by nameNamed imports (50)
@heroicons/react (outline)33,124 B5,805 B
react-icons (Lucide set)77,481 B3,983 B
lucide-react212,235 B5,545 B
@tabler/icons-react513,551 B3,438 B
@phosphor-icons/react1,049,588 B31,677 B

A bundler can't know which strings you'll look up at runtime, so it keeps every icon. Tabler goes from 3.4 KB to 514 KB, a factor of 150, and Phosphor passes a megabyte of gzip. The cheapest way out is the boring one: write the imports, or keep a small object that maps the handful of names you really use to components.

Which Library Should You Pick for Bundle Size?

Choose by design, then check the one trap. For a fixed set of icons, Tabler, react-icons, lucide-react and Heroicons are within a rounding error of each other, so pick the one whose drawings you like. If you'll use shadcn/ui, Lucide is already the default, and adding a second set would cost more than any of these differences.

Two rules do the real work. Never import * as Icons in code that ships to the browser unless the names truly come from data. And put a size budget on the entry chunk, as in this size-limit setup, so a name lookup added in a pull request fails the check instead of reaching production. If your build tool matters here, the Vite, webpack and esbuild comparison covers what each does with unused exports.

What Did This Not Measure?

Not much of the run is in doubt, but some things sit outside it. I measured production builds only, so dev-server cost isn't in the table. I measured bytes, not render time, and I didn't test lazy-loading routes such as lucide-react/dynamic. The 50 icons are everyday interface glyphs; a set of complicated illustrations would cost more per icon in every library. And these are one set of versions on one day, which is why the folder pins them and fails when a name disappears.

The react-icons page lists its icon packs and install options. For props and accessibility, the Lucide page linked at the top has the reference, and the size-limit guide linked above is the place to start if bundle budgets matter in your app.

Frequently Asked Questions

Does importing icons from a barrel file bloat a production build?
Not with a current Vite build. I imported 50 icons by name from the package root in five libraries (lucide-react 1.77.0, react-icons 5.7.0, Tabler 3.52.0, Phosphor 2.1.10, Heroicons 2.2.0) and each added only the icons I used, between 3.4 and 31.7 KB gzip in total. The bloat appears when you import the whole module and pick icons by string, which adds 33 KB to 1,050 KB.
How many bytes does one extra icon cost?
After the first icon, about 56 to 107 bytes gzip for lucide-react, react-icons, Tabler and Heroicons, and about 620 bytes for Phosphor. The first icon is dearer (395 to 1,458 bytes) because it pays for the wrapper component every other icon reuses.
Why is Phosphor so much heavier per icon?
Each Phosphor icon definition carries all six weights (thin, light, regular, bold, fill and duotone). I read the House definition in the 2.1.10 package and it contains all six, 2,662 bytes before compression, even if you render only one weight.
Is a name lookup like Icons[name] ever worth it?
Only when the names really come from data, such as a CMS menu or an icon picker. Then budget for the full package: 212 KB gzip for lucide-react and 514 KB for Tabler in my build. For a fixed set of icons, write the imports out or build a small map of the few you need.