Friday, April 15, 2022

svg optimization

SVG is an under-heralded format! The way it's text-based instead of binary, and so very embeddable, is great, plus the way it scales is just fantastic. 

Greg at work pointed me to which can optimize SVGs - claims shrinking so the final result is like a quarter the size.

One gotcha with React though, if embedding it as a React component (couldn't quite get raw .svg to be included as a a component directly in storybook and Gatsby, though flavors of webpack say they do it, so we wrap it as a proper React  .tsx component file) is you have to convert attributes with hypens into camelcase - fill-opacity to fillOpacity, for example...

No comments:

Post a Comment