Like you said, SVGs are vectors.
should I go for a smaller file size
You cannot shrink the file size of an SVG. The SVG's XML code remains the same even if you lower the SVG's stated DPI or pixel size.
Will the SVG's file size change if the viewBox
is changed?
It usually won't, or at least not much. Here's a convoluted example in which it WOULD change.
Here's the original ("small") version:
<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
<rect y="5" x="5" width="2" height="2"></rect>
<circle cx="5" cy="5" r="20%" fill="white"></circle>
</svg>
Now let's up the viewBox
size. We need to proportionally increase the absolute coordinates of all elements.
<svg viewBox="0 0 10000000 10000000" xmlns="http://www.w3.org/2000/svg">
<rect y="5000000" x="5000000" width="2000000" height="2000000"></rect>
<circle cx="5000000" cy="5000000" r="20%" fill="white"></circle>
</svg>
The result is the same image, but 48 bytes larger (28%!). 48 bytes larger FOR NO GOOD REASON - the represented image is exactly the same, with the same level of precision.
This example is convoluted because most SVGs won't be like this - they will use floating point numbers, and even if the decimal (the literal .
) position shifts, the number of digits will not - so there will be little or no size difference.
If you are changing the viewBox
size and rescaling all of the values and do see a difference, then it is either like the convoluted example above, OR you are actually losing precision because the rescale is reducing the number of digits in the floating point values -- which would reduce the quality of the final image.
M20.3 7.9L30.7 21.3
then consider multiplying the viewBox by 10 – Stirring