Load Devicon Icons as Individual SVGs Instead of the Web Font
Import only the Devicon SVGs you render, validate names with devicon.json, and avoid shipping the full webfont.
01 Apr 2026, 21:05 UTC

The problem: shipping a whole font for a few logos
Your UI shows technology logos - React, Node.js, PostgreSQL - and you reach for Devicon. The fastest way to add it is the bundled webfont and CSS, but that downloads the entire icon set even when a page uses only three icons. It can also cause a flash of unstyled text while the font loads, and it makes individual logos harder to style with CSS than inline SVG.
Useful takeaway: install the npm package, import only the SVG files you render, and validate icon names against devicon.json during your build. You ship less code, avoid font-loading layout shifts, and control color and size with ordinary CSS.
1. What changes when you use individual SVGs
A webfont bundles every glyph into one file, so the browser downloads icons you never display. Inline SVG ships only the markup for the icons on the current page. Because the SVG is part of the DOM, you can set fill, stroke, width, and height with standard CSS rules instead of relying on font-specific classes.
This approach does require a bundler or build step that can import SVG files. A plain HTML project that copies files by hand may still find the webfont simpler to drop in.
2. Add Devicon SVGs to your project
Run this in your project root:
npm install devicon
No special permissions are required beyond normal write access to the project folder. The command adds devicon to package.json and downloads fonts, CSS, SVG assets, and the devicon.json manifest.
After installation, confirm where the SVG files live in your release:
ls node_modules/devicon
Look for an icons directory or svg directory. The exact folder structure can change between releases, so do not hardcode a path without checking your installed copy.
Here is an illustrative component. The import syntax depends on your bundler; configure it to return inline markup or a URL, and verify the path against your installed package.
import ReactLogo from 'devicon/icons/react/react-original.svg';
export function TechIcon() {
return (
<span role='img' aria-label='React' dangerouslySetInnerHTML={{ __html: ReactLogo }} />
);
}
If your bundler returns a URL string instead of markup, use an img element with that URL as the src. Add role='img' and aria-label, or a title element, because inline SVG does not inherit font-icon accessibility conventions by default.
3. Check icon names before they break
Devicon publishes devicon.json, a manifest mapping technology names to icon files. You can read it at build time to catch typos and missing icons before deployment.
Save this as check-devicon.mjs and run it from your project root with node check-devicon.mjs:
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const manifestPath = join(__dirname, 'node_modules/devicon/devicon.json');
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
const knownNames = new Set(manifest.map((icon) => icon.name));
const required = ['react', 'nodejs', 'postgresql'];
const missing = required.filter((name) => !knownNames.has(name));
if (missing.length > 0) {
console.error('Devicon manifest is missing:', missing.join(', '));
process.exit(1);
}
Expected result for valid names: silent exit code 0. If a name is missing, the script prints the missing names and exits with code 1. Risk: the manifest shape may change between Devicon releases; inspect devicon.json if the script throws.
4. Trade-offs and limits
- Requires a build step or bundler that handles SVG imports.
- Not every technology has both plain and colored variants; confirm the variant file exists before assuming it.
- Icon names and file paths can change between releases. Re-run the name check after upgrading Devicon.
- SVG icons do not carry font-icon accessibility conventions by default; add titles and aria attributes manually where needed.
Rollback
This change only affects project dependencies and frontend code. If it causes build failures, uninstall the package and revert your imports:
npm uninstall devicon
Then remove the SVG import statements and redeploy. No production data rollback is needed.
Practical check before shipping
Render one icon in a local test page, open browser DevTools, and confirm the SVG has a viewBox and that CSS fill changes its color. Use your bundler's analyzer to compare the gzipped size of the previous font bundle against the bundle with selected SVGs. Verify exact paths and behavior against your installed Devicon version before deploying to production.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.