Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering SVG

You're reading from   Mastering SVG Ace web animations, visualizations, and vector graphics with HTML, CSS, and JavaScript

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781788626743
Length 312 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Rob Larsen Rob Larsen
Author Profile Icon Rob Larsen
Rob Larsen
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Introducing Scalable Vector Graphics FREE CHAPTER 2. Getting Started with Authoring SVG 3. Digging Deeper with SVG Authoring 4. Using SVG in HTML 5. Working with SVG and CSS 6. JavaScript and SVG 7. Common JavaScript Libraries and SVG 8. SVG Animation and Visualizations 9. Helper Libraries Snap.svg and SVG.js 10. Working with D3.js 11. Tools to Optimize Your SVG 12. Other Books You May Enjoy

SVGO


SVG Optimizer (https://github.com/svg/svgo) is a Node.js utility for optimizing SVG files. SVG files, especially those generated by editors, can have a lot of cruft associated with them. SVGO can clean up the metadata, comments, hidden elements, and so on, without changing the rendering of the SVG element itself.

To install it, assuming you have Node.js installed, run the following on the command line:

$ npm install -g svgo

Usage is as simple as this: 

svgo svgo.svg

Running that on a small file generated by Inkscape, reduces the file size by over 50 percent:

The difference is apparent if you look at the change in the svgo.svg source code, before and after optimization.

The following screenshot shows the metadata added by Inkscape during the authoring process:

This screenshot shows the cleaned-up file after optimization:

It's a great tool, with many configuration options (https://github.com/svg/svgo#usage) and integrations with other tools (https://github.com/svg/svgo#other-ways-to-use-svgo)...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime