Why Optimize?
- Faster page load times
- Better Core Web Vitals scores
- Reduced bandwidth usage
- Typical savings: 20-80% file size reduction
SVGO (Recommended Tool)
The standard optimization tool for SVG files:
# Install
npm install -g svgo
# Optimize single file
svgo input.svg -o output.svg
# Optimize folder
svgo -f ./icons
What SVGO Does
- Removes metadata and comments
- Removes default/unused attributes
- Rounds numbers to fewer decimals
- Merges paths when possible
- Removes empty groups and containers
- Converts shapes to paths (optional)
Manual Optimization Tips
1. Simplify Paths
// Before
d="M 10.000 20.000 L 30.000 40.000"
// After
d="M10 20L30 40"
2. Remove Unnecessary Attributes
// Remove default values
fill="black" // black is default
stroke-width="1" // 1 is default
3. Use Presentation Attributes
// Style attribute (verbose)
style="fill:#ff0000;stroke:#000000"
// Presentation attributes (shorter)
fill="#f00" stroke="#000"
4. Reduce Decimal Precision
// Before
d="M 12.3456789 45.6789012"
// After
d="M12.35 45.68"
Online Tools
- SVGOMG - GUI for SVGO
- SVG Minify
Compression Checklist
- Export cleanly from design tool
- Run through SVGO
- Remove hidden layers/elements
- Consider GZIP compression on server
- Test visual appearance