DEV Community

Cover image for SVG Cleanup
JS Bits Bill
JS Bits Bill

Posted on • Edited on

5 1

SVG Cleanup

Sometimes you'll look inside the markup of an SVG file and you'll see a TON of extra data that is almost definitely superfluous:

svg-source

I came across this great tool called SVGOMG, by Jake Archibald, which lets you easily toggle SVG features like doctype, comments, metadata, etc. to reduce the file size:

svgomg-1

As you toggle options you'll see how much savings the new file will have. When you're done you'll be able to copy or download the smaller output:

svgomg-2

I particularly love the realtime preview the tool has so you can see how the quality stays as you toggle options. And it's also great for devs like me who have OCD about unnecessary code! 🧼

Here's a quick video of how to use it:


SVG cleanup


Check out more #JSBits at my blog, jsbits-yo.com. Or follow me on Twitter and TikTok.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (1)

Collapse
 
duhdugg profile image
Doug Elkin

This is powered by svgo, which is what I use when optimizing SVG files. I would personally prefer the CLI for this. It's quicker because it edits files in-place (no needing to open + download and replace file using a web browser), and it also allows multiple files at once. That said, cool project, and nice article!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay