I Minimizing SVG File Sizes
This appendix is informative.
Considerable effort has been made to make SVG file sizes as
small as possible while still retaining the benefits of XML and
achieving compatibility and leverage with other W3C
specifications.
Here are some of the features in SVG that promote small file
sizes:
- SVG's path data definition was defined to produce a compact
data stream for vector graphics data: all commands are one
character in length; relative coordinates are available; separator
characters do not have to be supplied when tokens can be identified
implicitly; smooth curve formulations are available (cubic Béziers,
quadratic Béziers and elliptical arcs) to prevent the need to
tessellate into polylines; and shortcut formulations exist for
common forms of cubic Bézier segments, quadratic Bézier segments,
and horizontal and vertical straight line segments so that the
minimum number of coordinates need to be specified.
- Text can be specified using XML content -- no
need to convert to outlines.
- SVG contains a facility for defining symbols once and
referencing them multiple times using different visual attributes,
different sizing and positioning.
Additionally, HTTP/1.1 allows for compressed data to be passed
from server to client, which can result in significant file size
reduction. Here are some sample compression results using gzip compression on SVG
documents:
Uncompressed
SVG |
With gzip
compression |
Compression
ratio |
12,912 |
2,463 |
81% |
12,164 |
2,553 |
79% |
11,613 |
2,617 |
77% |
18,689 |
4,077 |
78% |
13,024 |
2,041 |
84% |
A related issue is progressive rendering. Some SVG viewers will
support:
- the ability to display the first parts of an SVG document
fragments as the remainder of the document is downloaded from the
server; thus, the user will see part of the SVG drawing right away
and interact with it, even if the SVG file size is large.
- delayed downloading of images and
fonts.
Just like some HTML browsers, some SVG viewers will download images
and <a href="http://www.w3.org/TR/REC-CSS2/fo f