← Back to Blog

Reducing Bundle Size: The Hidden Cost of Inline SVGs in React

2026-01-056 min readPerformance

We love inline SVGs in React. They are easy to style, easy to animate, and easy to copy-paste from Figma. But they are silently killing your app's performance.

The JavaScript Bloat Problem

When you paste a 50KB SVG directly into your React component, you aren't just adding an image. You are adding 50KB of JavaScript.

React has to:

  • Parse that huge string as code.
  • Create thousands of Virtual DOM nodes for every <path> and <g>.
  • Hydrate those nodes on the client side.

This drastically increases your Total Blocking Time (TBT). I recently audited a Next.js landing page that had a 400KB "illustration" as an inline SVG. It delayed the First Input Delay (FID) by 300ms on mobile devices.

The "Figma Junk" Factor

Designers love grouping things. Figma exports reflect that. A simple icon often contains:

<g id="Group_123"> <g id="Group_456"> <path id="Vector" ... /> <!-- Hidden layers often get exported too! --> </g> </g>

Every nested group is another DOM node. Every useless ID adds bytes. Every hidden layer that wasn't removed is dead weight.

The Solution: Clean, Minify, or Externalize

1. Use an SVG Cleaner (Essential)

Before you paste any SVG into your codebase, it MUST be cleaned. You need to strip IDs, collapse groups, and reduce precision.

I built Vector Gnome specifically for this. It runs SVGO in the browser via WebAssembly, so you can clean sensitive assets without uploading them.

2. The "Img" Tag Strategy

If you don't need to change the color of the icon on hover, do not use inline SVG.

Save it as a .svg file in your public folder and use:

<Image src="/icons/logo.svg" width={24} height={24} alt="Logo" />

This keeps the SVG out of your JS bundle. It loads asynchronously and doesn't block hydration.

2026 Optimization Checklist

  • Audit: Check your bundle analyzer for large SVG modules.
  • Clean: Run every asset through Vector Gnome.
  • Decide: Interactive? Inline it. Static? <img> it.

Need to fix your assets now?

Vector Gnome provides a free diagnostic tool to check your SVGs for React performance issues.

Run Diagnostic