Has the time come for web designers to embrace the SVG image format?

vector graphics

Display resolutions are increasing every year, something that’s being taken to its extreme with the recent “retina display” trend that came with the latest iPad. The jump in onscreen pixels is massive, and such displays are soon bound to make their way into regular laptops and desktop displays, perhaps as soon as this year.

This development will have a profound effect on the size of the graphics resources necessary for websites, which ultimately will make websites bigger, more bloated and slower to download. That is, if we don’t change tactics.

The growing footprint of bitmap graphics

High-resolution monitors place increasing demands on the resolution of our graphics resources. For example, most of today’s monitors of good quality have around 110-130 PPI (pixels per inch). A retina display like that on the new iPad has around 300 PPI.

A square image with a side of 5 inches on a 130 PPI screen is 650×650 pixels. On a 300 PPI screen an image with the same dimensions would be have to be 1500×1500 pixels.

So, going from 130 to 300 PPI, the same 5-inch square image goes from containing 422,500 pixels to containing 2,250,000 pixels. That’s more than 5 times as many.

In other words, serving increasingly large images with bitmap graphics formats like JPG and PNG is becoming impractical, or at least inefficient.

All web page resources are growing in size year over year, but images account for such a large part of the average web page size that they have a bigger impact than for example CSS or HTML files. Keeping their size in check is very important.

Enter SVG and resolution independence

Modern browsers support SVG, a scalable vector graphics format (a cookie if you guess what the acronym stands for…). You’ve most likely heard of it, maybe even played around with it. SVG is standardized and has been around for years, but isn’t used much in web design today, most likely due to the poor browser support it used to have.

The benefit of vector graphics is that it’s resolution-independent and has a small memory footprint. The same image data can be rendered to a low resolution or a super-high resolution, it can scale indefinitely without any loss in quality.

Not all graphics resources are suitable for vector formats, of course. Photos are poor candidates for SVG. However, a lot of the graphics on the Web is made up of illustrations and icons, which are perfect for vector graphics.

Use of vector graphics future-proofs those resources, at least in terms of supported display resolutions. Check out the Emacs for Mac OS X site, for example, which totals in at a mere 21 kB, all resources included, and is scalable to any resolution (open it, resize the browser window to see it in effect).

Also, since SVG is a text-based markup language (XML-based), it compresses nicely with standard gzip, making the transfer size even smaller when people load your website.

Is browser support good enough?

Browsers with basic SVG support include Internet Explorer 9 and later, Firefox 4 and later, Chrome 4 and later, Safari 4 and later, Opera 9.5 and later. These account for around 80% of the web browsers in use today according to StatCounter data for May.

Check out CanIUse.com for more details on SVG feature support in different browsers.

Remember, you can always have a fallback option, a version of the site that uses pre-rendered JPG and/or PNG images if you detect that the browser doesn’t have SVG support. And no one says you need to use SVG for everything.

The tools are already there

It’s not like designers are handicapped when it comes to creating SVG content. The vector graphics tool chain is already in place, thanks to applications like Adobe Illustrator. There are even free, open source options, such as Inkscape.

Most logos and many icons are already designed with vector graphics, and it’s common in print. The translation to Web should be relatively straightforward. Famous last words, we know, but people are already proving it can be done, and done with style.

Conclusion

In short, web designers could use SVG to a much larger extent than they do today. It may not be suitable for all kinds of content, but there are plenty of websites that would benefit from it.

The win is a smaller memory footprint (faster download), and resolution independence. This will become increasingly important as more high-resolution monitors come into the market.

Wouldn’t it be nice to have a website where all graphics automatically matches the screen resolution perfectly, and not have to worry that your site looks like a pixelated mess on that new iPad retina display?

What now?

If you want to dive right in and explore the world of SVG for web design, A List Apart has an excellent primer by Shelley Powers (don’t miss that there’s a part 2). You might also want to check out this introductory article by David Bushell over at Smashing Magazine. You can also head over to W3Schools for an introduction.

Image credit: Top image via Shutterstock.

5 comments

  1. OK, I”ll admit that I’m no expert on SVG, but after reading the cited articles, I’d suggest that you’re raising false hopes when you write: “Wouldn’t it be nice to have a website where all graphics automatically matches the screen resolution perfectly”
     
    The real challenge is how to serve photos of reasonable filesizes that look good on both normal and Retina-type displays. Unless I’m badly mistaken, SVG isn’t the solution to that problem.
     
     

    1.  @Durant Imboden As stated, SVG is far from ideal for photos, but works well for a lot of other image types. Regarding photos, perhaps it’s time for W3C to blow the dust off the good old JPEG 2000 format, which should be pretty useful for scalable photos… Current browser support for that is poor, though. http://en.wikipedia.org/wiki/JPEG_2000

  2. I’ve done some extensive work on implementing SVG sprites and it has been a bit of a fail in that respect. SVG is great for single stand-alone graphics but start trying to use background positioning like you would expect from, say, a PNG sprite (but via em measurements) and you’ll quickly notice images getting antialiased all wrong in some browsers – even between different webkit-based browsers (mobile and desktop). It may be due to rounding errors in browsers and the way they rasterise the SVG before displaying it.
     
    Also, until such things as being able to target IDs within SVG files served as CSS backgrounds are supported in more browsers, we can effectively forget about SVG stacks too as they would be perfect for serving icon sprites: http://simurai.com/post/20251013889/svg-stacks.
     
    At the moment I’ve fallen back to using a SVG webfont for serving icons, which is OK but not as good as a pure SVG solution.

Leave a Reply

Comments are moderated and not published in real time. All comments that are not related to the post will be removed.