| 1 | --- |
| 2 | title: Optimize SVG Precision |
| 3 | impact: LOW |
| 4 | impactDescription: reduces file size |
| 5 | tags: rendering, svg, optimization, svgo |
| 6 | --- |
| 7 | |
| 8 | ## Optimize SVG Precision |
| 9 | |
| 10 | Reduce SVG coordinate precision to decrease file size. The optimal precision depends on the viewBox size, but in general reducing precision should be considered. |
| 11 | |
| 12 | **Incorrect (excessive precision):** |
| 13 | |
| 14 | ```svg |
| 15 | <path d="M 10.293847 20.847362 L 30.938472 40.192837" /> |
| 16 | ``` |
| 17 | |
| 18 | **Correct (1 decimal place):** |
| 19 | |
| 20 | ```svg |
| 21 | <path d="M 10.3 20.8 L 30.9 40.2" /> |
| 22 | ``` |
| 23 | |
| 24 | **Automate with SVGO:** |
| 25 | |
| 26 | ```bash |
| 27 | npx svgo --precision=1 --multipass icon.svg |
| 28 | ``` |
| 29 |