Why does svgo remove everything when minimizing an svg with symbols?

1.7k views Asked by At

Looking at svg minimization options, I found svgo https://github.com/svg/svgo . I successfully tried it with svg generated from illustrator, however, when I run it against the following, the resulting file is completely blank.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">

  <symbol id="beaker" viewBox="214.7 0 182.6 792">
    <!-- <path>s and whatever other shapes in here -->  
  </symbol>

  <symbol id="shape-icon-2" viewBox="0 26 100 48">
    <!-- <path>s and whatever other shapes in here -->  
  </symbol>

</svg>

I haven't been able to find a reason why this occurs.

2

There are 2 answers

0
zzarbi On

style="display: none;"

This is causing SVGO to think you don't need the block which mean it will empty the entire file. I'm not sure how to prevent this either

0
Kevin On

It can be prevented by passing an option to the plugin removeHiddenElems, displayNone: false