Why Aren’t You Using SVG?

Why Aren’t You Using SVG?

Tutorial Details
  • Languages: JavaScript, HTML, SVG
  • Difficulty: Medium
  • Estimated Completion Time: 30 Minutes

SVG, or Scalable Vector Graphics, is a XML-style markup driven vector graphic rendering engine for the browser. SVG is supported in every browser, except IE < v9 and Android < v3. The same support is available for canvas (except canvas goes all the way back on Android), so the question often surfaces: which one should you use?

Today, we will survey SVG, and explain why the question of “which one should I use?” is usually answered by “what am I trying to do?”. To get a full list of elements that make up SVG, check out Mozilla’s docs on the subject. You can see the SVG DOM API there as well.


Overview

We’ll begin by outlining some unique advantages of SVG. Then, instead of reviewing all 80 SVG node types, we will explain how Illustrator can quickly get an SVG document into a web page. We’ll also take a look at D3.js, a powerful SVG manipulation JavaScript library.

“SVG is not meant to be used for pixel manipulation.”


Major Advantages of SVG

SVG has quite a few advantages over images or canvas-based renderings for certain applications. SVG is not meant to be used for pixel manipulation; however, it handles vector graphics and programmatic vector manipulation very well.

Resolution Independence

In case you haven’t heard, resolution independence and browser agnosticism is a hot topic in front-end development (think “responsive design”) these days. Most of the solutions that exist to fix resolution-based issues (for retina screens, for instance) involve either a large amount of unnecessary data downloaded (hi-res image replacement) or compromise for one browser or the other (upping all resolutions, even when the screen won’t display the difference). This makes us rely on the speed of the data download-speed bottleneck to bring higher resolution images to devices that are often on wireless data networks. Not ideal.

“SVG offers a way to do full resolution graphical elements, no matter what size screen, what zoom level, or what resolution your user’s device has.”

SVG offers a way to do full resolution graphical elements, no matter what size screen, what zoom level, or what resolution your user’s device has. This is something that up until SVG, we only saw with clever element styling via CSS and text rendering. Using divs and :after elements to create simple shapes and other effects is unnecessary with SVG. Instead, you can create vector shapes of all kinds.

Super-Accessible DOM Node-Based API

So you write HTML? JavaScript? CSS? Good. Then you already know a lot of what you need to know to get writing SVG. SVG actually uses an XML-compatible format to define its rendering shapes. Beyond this, you can actually style shapes in CSS, and make them interactive with JavaScript. Multiple JS libraries exist to assist you in this world, like D3.js and Raphael. Here’s an example of an SVG element group (the Envato leaf). You can also see this example on JSFiddle.

<svg>
<g>
	<g>
		<path fill="#8BAC54" d="M28.028,104.509c-35.271,44.527-36.619,105.084-7.616,150.407
			c26.073-66.957,58.919-142.287,99.378-209.543C81.802,61.428,46.351,81.377,28.028,104.509z M278.797,11.28
			c-0.408-3.492-2.227-6.447-4.845-8.41c-2.5-2.097-5.802-3.197-9.304-2.784c0,0-10.403,2.227-26.959,6.483
			C158.62,82.498,93.735,184.229,43.453,281.932c1.875,1.628,3.778,3.255,5.749,4.794c56.202,44.471,137.782,34.972,182.238-21.163
			C282.657,200.806,278.797,11.28,278.797,11.28z"/>
	</g>
	<g>
		<path fill="#B1C982" d="M58.392,293.368c59.428-95.491,133.438-188.549,220.117-247.851c0.558-20.869,0.289-34.238,0.289-34.238
			c-0.408-3.492-2.227-6.447-4.845-8.41c-2.5-2.097-5.802-3.197-9.304-2.784c0,0-10.403,2.227-26.959,6.483
			C158.62,82.498,93.735,184.229,43.453,281.932c1.875,1.628,3.778,3.255,5.749,4.794C52.185,289.102,55.271,291.308,58.392,293.368
			z"/>
	</g>
</g>
</svg>

The DOM node-based API of SVG is already more accessible than the client-side only canvas API. With this construction you can:

  • Create SVG document-based images on the server-side
  • Inspect SVG elements like any other HTML element
  • Programatically manipulate shapes, styles, and positions with technology you are already familiar with (JavaScript and CSS)
  • Attach event handlers to SVG nodes

The DOM API provides a further set of clear advantages for using SVG.

No Unnecessary HTTP Requests

When you use images in an html document with the <img> tag, you are defining a file that the user’s browser will request. This request will take up bandwidth and require more precious time to download. If your image is instead a set of dom nodes, it cuts that extra HTTP request out, making your website faster and more user friendly.

Easy Interactive Scripting

Despite the browser wars, the DOM API, across all browsers, offers an extensive amount of flexibility in terms of scripting interactivity, which extends to SVG elements. Styling SVG happens through CSS. Having browser event APIs available to SVG elements makes interactive behavior scripting a cinch. Simply attach a handler to a specific node of the SVG element, and you’re set.

This is not true for elements drawn onto the canvas. Since the canvas is simply a pixel rendering engine, the drawn elements are not kept in memory as objects. The script would have the job of keeping these elements collected, and monitoring all relevant position and size information to look for and fire events in an event loop. Beyond this, z-indexing would have to be handled by the script as well.

Let’s take a look at an example. Say you want to detect hover over a circle in canvas. Note: We’ll just say the canvas is the full width of the browser window, and we’ll use jQuery just to keep the example concise.

var circleCenter = [200, 300], radius = 50;
$(window).on("mousemove", function(e){
	var mx = e.pageX, my = e.pageY;
	if (mx > circleCenter[0] - radius && mx < circleCenter[0] + radius && my > circleCenter[1] - radius && my < circleCenter[1] + radius){
		// now we are hovering
	}

});

While this isn’t necessarily a difficult or uncommon pattern of code, if you’re used to the browser API, it seems like a frustrating process just to check for hover. This is a very common pattern in other lower-level interface programming engines like Unity3D or Processing. But in the web world, we have tools at our disposal that already handle a lot of common interactive goals we may have. You could write a set of convenience functions to do common tasks, but wouldn’t you rather get to the point? In contrast, we can see the simplicity of the same task using SVG.

$("svg path#circle").on("hover", function(event){
	// That's all.
});

This is clearly far more time-efficient for developers scripting simple interactivity.


Practical Applications

There are plenty of JavaScript libraries out there for canvas (like KineticJS, which will let you do some pretty awesome stuff. But if you’re like me, you’re not using full-on physics engines in your web applications. Instead, I’m most often needing scalable icons, interactive graphs, and detailed, aesthetically gorgeous ways of presenting information to my users. Most of the physics I need are simple easing equations. These graphical elements are easily created with SVG, and a multitude of simple physics equations will probably handle the rest of my needs. So let’s look at a few practical applications for SVG.

  • Graph
    Because SVG’s biggest strength is basic vector shapes, it naturally works very well for graphs and infographics. Not only is it great for creating static graphs from given numbers, but it is also well suited for “live” graphs, fed by AJAX requests, user input, or randomly generated data.
  • Road Map
    Road maps consist of hard lines and exact shapes. These shapes can be represented well with vector graphics, and lend themselves to zooming into the map for further detail.
  • Complex UI elements
    Let’s say you wanted a UI element that looked like a stacked pyramid of circles. How would you do this in HTML and CSS? Well, you’d first create a bunch of divs for each hole, giving them each a certain border radius and border styles. Then you’d position them within a containing div. Now, what if you wanted a single gradient over the whole thing? You’d likely have to use masking, or some other technique. You’d rather not use images, as they aren’t scalable and can’t be programmatically re-rendered or changed. Instead, why not draw the element in Illustrator, and save it out as an SVG file? This would allow you to have a single, scalable element without worrying about managing multiple divs.
  • Logos
    Most logos are vector-based. You could define an SVG document as your logo, and drop it anywhere, scaling on the fly to whatever size it needs to be without compromising quality or taking up too much bandwidth.
  • Simple Games
    It’s no secret that canvas is suited well for game rendering. Part of the reason for this is that games are often not dependent on vector graphics; rather, they use pixel-based art and animation. However, SVG is a great alternative for games that require less character animation and more information display (think Sudoku).

Why You Probably Aren’t Using It

Now that we’ve looked at some of the advantages of SVG, let’s examine why many developers still choose not to use SVG. There are two main reasons why SVG isn’t being used by a lot of developers.

  1. They have never heard of it or have never thought they needed it, so have ignored it (This one is no longer an excuse!)
  2. An SVG XML document of any complexity looks relatively archaic and complicated, and seemingly isn’t nearly as easy as just using an image.

So of course, nobody really wants to sit and edit the points in the SVG XML. Luckily, no one needs to! This is the part that people often don’t realize; there ARE tools to edit SVG, so you don’t ever have to do it by hand.


SVG Tools

Illustrator, Inkscape

If you own a vector editor, it most likely can save your file as an svg. Go ahead and try it out. Open Illustrator, draw a circle or two, and then save the file as SVG. Next, open that file in Sublime Text or another text editor. You’ll immediately see that, aside from some extra meta data, the SVG XML is ready to drop right into your HTML file. You’ll most likely see <g> (group), <path> (path), and of course <svg> (the parent svg) elements.

D3.js

While you are totally able to drop your SVG XML directly into an HTML file, what if you want the SVG to be dynamically created? D3.js is “a JavaScript library for manipulating documents based on data”. In other words, it’s great for generating SVG elements like bar graphs and line plots based on a set of data. We’ve chosen to show D3 because of its matching vocabulary to the actual SVG implementation in the browser; be aware that there are other great SVG libraries out in the wild (notably, Raphael.js).

Although D3.js does more than SVG manipulation, for the sake of brevity, that is all we will use it for today. (Make sure you take a look at the examples at the D3.js official site, and check out this workshop Mike has posted on his personal site.)

Example 1: Pulsing Circle

In this first example, we are simply creating a pulsing circle by using Math.sin and an iterator with a setInterval.
Pulsing Circle

Example 2: Updating Line Plot

In this example, we are updating a plotted line graph with some random values.
Line graph


When Should You NOT use SVG?

SVG will handle a lot of your needs for in-browser image rendering. While there are plenty of reasons to use SVG, as with anything great, there are things that it doesn’t do well.

  • If your rendering requires thousands of nodes, it’s more performant to do the rendering in canvas (as the browser isn’t having to create objects for every piece rendered, and also doesn’t have to do the vector math required to render the object. Instead, it essentially paints mapped pixels.)
  • If your application requires support for IE8, remember that you must either provide another vector fallback (such as the more convoluted VML) or not use vector at all, and instead rely on responsively sized images.

Helpful Links

Here are a few helpful links to get you further entrenched in SVG!

What other uses have you found for SVG? Let us know in the comment section and thank you so much for reading.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Cam

    I think the lack of IE8 support is the main reason I don’t use it. No one likes more things to check compatibility on.

    • tom

      Try Raphael.JS.
      It has some compatible replacement for IE and it’s easier than the regular svg programming.

  • LessLessMoreMore

    Good article. Bad title. I hate that so many tutorials the web over have titles like, “You’re a bad web developer if you’re using this and not the thing I prefer,” or, “If you use this practice over others, you suck. Why aren’t you following this fad yet???” They hammer opinions into our heads like they’re obligatory practices, all when the author is nothing more than biased.

    As for why I am not using them: overall browser support, and because I don’t want to (I haven’t been using raster images for over 12 years to suddenly make all of my web graphics as vectors just because of the stupid iPad). They seem ideal for games, especially now that Flash is so hated, simple logos, small graphics like stylized bullets and dividers, etc. But a lot of people are saying we should use them for all web graphics, namely because of the emergence of the new iPad and it’s super high-res display. I say “bullroar” to that.

    • Julian

      Your in the wrong field my friend if you’re disregarding the future. You should try becoming a locksmith instead.

    • Jesus Bejarano

      Agree, but still we should atleast give it a try just for experiment it , is not going to kill us.

    • Adam

      Flash isn’t so hated – any although the web is getting beter, nothing out there can touch flash for what it does. FACT.

    • AntoxaGray

      Who said you SHOULD use it for all graphics?

      Personally, I would use SVG if I needed some vector animation.

  • NakkiNyan

    I will use it when the author personally goes to everyone’s home and forces them to upgrade or switch from IE. Until that point it is not worth my effort or the hatemail®.

    • andy

      Here here, all of the “cool” tools people claim everyone should be using is getting a little old. Not because the tools arent great, but because the browser that most normal people are using, does not support it. So whats the point…

      • NakkiNyan

        Most people I help buy a computer and the first thing they do is turn off automatic updates because : “it’s annoying”; of course they never do it on their own so there are people out there still with Windows XP and no service packs let alone IE updates…

  • http://www.rmwebs.net Rick

    As above. It’s all well and good having a fancy article about this, which I’m sure took a lot of work (and was very insightful) but it ends up being near useless as no sane developer will alienate such a huge chunk of their audience (even tho said chunk of audience are likely to be light-users due to the fact that they are using IE at all).

    Sorry, but SVG wont be used in a live environment for a long time yet.

    • http://viget.com Tommy

      We are using SVG for the treadmill on http://www.puma.com/bringmeback

      It allows for starting/stopping and doing both smoothly.

      The fact is most users don’t use IE8.* For those that do, show them a graphic instead. And for everyone else, give them a better experience. The trend is going towards SVG, not away from it. You can slow it down or you can speed it up. I prefer to speed it up.

      *http://www.w3schools.com/browsers/browsers_stats.asp

      • Andrew

        Hey, good use of SVN on the treadmill, I like it.

    • http://cmrnolvr.com Cameron

      Ironically – I developed an SVG graphing script in 2006 and at that point IE was THE ONLY browser doing it properly. I had the most issues with Firefox. Granted, IE needed an activeX install, but once that was done it worked great.

      Unfortunately because of the FF issue we had to turf it and ended up using some png graphing solution…

  • http://www.adamcrooker.com adamTheGr8t

    I think SVG will become widely used and accepted the minute apple releases actual computers with retina screens. (fingers crossed for new i-macs with retina screens)

    • LessLessMoreMore

      Sadly, it’s probably true. While they won’t become the de facto web graphic, I hope, they will become a massive trend. Apple may not truly dictate how the web works, but they are the brainwashing trend setters. Face it, people act like they didn’t, trying to cite reasons apple spoon-fed to them, like how it was naturally bad and claiming they all hated it all along, but people basically just started hating Flash because Apple told them to. Having to undo how people have made web graphics for over 20 years just because you release one new type of screen is kinda silly. I vote that we keep making them the same, and Mac people just use their money-blowing habits to ensure they always have the internet speeds to load huge raster graphics. We can call it the “suck on this” media query.

      • http://whiteboard.is Jonathan Cutrell

        I feel like this comment may be slightly short-sighted.

        It’s not just a “type of screen” that causes this problem. It’s a resolution issue. Apple isn’t the problem with “the way you’ve done web graphics for over 20 years”. I dare to say that the way you’ve done web graphics for 20 years WILL change with technology. Retina-density screens will be coming to more devices than just iPhones and iPads. Apple happens to have a pretty huge pull in the hardware game because of the size of their company; often times, what they do, others follow. The reason for this is arguably entirely monetary.

        Connecting SVG to “Mac people’s money-blowing habits” is a far stretch. Technology will continue to move forward, and someone will be the first to make changes that call for developers to change their workflows (whether that’s Apple or some other company).

  • http://thomasv.nl ThomasV

    Already using it within a cool project made!

  • Ark-kun

    scalable, scalable, scalable, scalable, scalable, scalable, scalable, scalable…

    Is SVG really scalable on the web?
    Have you ever tried to scale SVG? I dare you to try.

    This is an SVG logo in svg format: http://upload.wikimedia.org/wikipedia/en/c/ce/SVG-logo.svg
    Try to insert it as an external image on this very page of your blog. It’s too large, so you’ll need to scale it =)

    • Andesh

      Ignorance is bliss, my friend, Ignorance is bliss.

    • Andrew Dunn

      The exact same way you scale any image on the internet.
      http://jsfiddle.net/QNyPE/

  • YT

    Thanks for the useful info. Yes, usually SVG is used for some small / simple application / project, such as chart, graph, statistic and etc. Recently, I found a tutorial that teach how to generate a SVG Chart using Google Chart API Library, so here is the link to you guys who are interested to step deeper into SVG: http://www.onlywebpro.com/2012/05/11/a-complete-guide-to-create-an-animated-svg-chart/

  • http://people.opera.com/danield/ Daniel Davis

    Why aren’t I using SVG?

    Android

    No support prior to Honeycomb in the default browser, and pre-Honeycomb devices will be around for a long time yet.

    • david

      I second this. This is the primary reason.

  • Abhijit

    I have been using SVG, especially Raphael js. I have found that SVG really slows down a lot if you have a big number of elements. I am not sure if canvas is better it terms of performance, but SVG does seem poor.

    • http://whiteboard.is Jonathan Cutrell

      SVG will slow down after about 500 elements in most browsers. Strangely enough, IE10 actually takes the cake on fastest SVG implementation.

      Canvas will virtually not slow down (unless you are looping over a ton of large objects in your code and redrawing every frame or something). It doesn’t modify the dom at all, actually.

    • YT

      Yes. May be is caused by its large amount of DOM Nodes. That’s why I prefer Canvas when dealing with big project.

    • http://techishard.wordpress.com/ Grant

      Part of the issue is using a library of code to render SVG. When I did with straight SVG, there are simple ways to drastically reduce the load through reuse.

      What you’re judging is how Raphael creates SVG from its input, not SVG itself. If one an inefficient compiler, would one say the machine language is slow?

      • http://www.ricalsin.com Ricalsin

        Grant, can you provide some helpful links regarding your comment?

  • Robin

    Fireworks also has an export plugin that can do basic exports to SVG

    http://fireworks.abeall.com/extensions/#Export

  • Marc Almada

    I’m in hate with SVG implementation. Why couldn’t they have used CSS for formatting elements and parameters to describe geometry only. We can’t even group objects natively. These specs are too bad. SVG is very useful but very unpleasant to work with IMMO.

  • http://stickmanproject.com/ Edgard

    Ever since I found about SVG, I have been using it for my projects for many reasons. One of them is a little improvement on accessibility: as SVG does not distort when zoomed, a person used to zoom web pages for better view will profit of better images.
    Also, there SVG is the best option for icons.

    As of supporting non-SVG browsers, well, I know many will disagree with me, but I sincerely don’t care that much for them, especially when talking about IE 8 and previous versions.
    Recently, upon viewing the access statistics of a website I built for a friend, I was surprised that most IE users are using IE 9 (although IE 8 is few points behind). And an important note: the website is intended for a public which generally has no knowledge of web technology.
    I do understand that many developers need to support old browsers, but I think that we should care less about them (the old browsers). I mean, how will IE users realize they need to update their browsers if we keep supporting them?

    Also, support non-SVG browsers is easy. There is no need of big checks, simply use the object tag, like this:

    <object type=”image/svg+xml” data=”path_to_svg_file”>
    <img src=”path_to_fallback”>
    </object>

  • http://www.musings.it Federica

    I’m using SVG (even for a client’s project right now) and I’m very happy about the possibilities and the results it gives if coupled with jQuery. I’m not using Raphael.js because even though it’s a great library with tons of features, it’s very heavy and slow and most of the time I don’t need every single feature but only a bunch of them.
    As to cross-browser issues, I think all browser will add some sort of SVG support in the near future thus I’m not worried at all about it (also CSS3 and HTML5 experienced these weird periods with features sopported or non-supported by various browsers); of course we have to provide some fallbacks or warning in the meantime. If you’d like how I did some time ago here’s the SVG – jQuery experiment I did las Christmas: http://www.myxmascard.it Enjoy!

  • Ivan

    “SVG is supported in every browser, except IE < v9 "

    =

    at least 20% browsers are not browsers

  • Seth

    I recently built an HTML5 game with vector art and exported the illustrator file to both SVG and Canvas (via AI2Canvas).

    The built-in SVG exporter in AI works great (once you understand the confusing versioning of SVG), and I love that it can be used as the src of an img or background in HTML5.

    AI to Canvas rendered identical results, except it wasnt cropped properly, obviously a limitation of AI2Canvas.

    Anyways, I threw out the SVG as soon as I started to notice the relative performance on Mobile Safari – its enormous and Canvas is much, much faster. I’m using vector graphics for adaptive design, so when parameters change, the reflow has to happen immediately, that wasn’t my experience with SVG.

    I think the reason for this is that webkit and other browser engines are simply under a lot more pressure to optimize Canvas than SVG due to popular demand. SVG never enjoyed the adoption rate Canvas has seen on the web, and I think that’s for the same reason JSON eclipsed XML so quickly….XML is kind of unnecessarily bulky and ugly.

    To be honest, I’ve never cared for XML either and don’t like mixing it into my JS and HTML.

  • http://weedygarden.net Erik Runyon

    We’re using SVG’s on a couple of Notre Dame projects for logo’s. One as an inline image and the other as a background image. In both cases we just provide a fallback png for devices that can’t handle it. So far so good.

  • http://www.francisthibault.com Francis Thibault

    I’ve used svg on a recent project, quality is awesome when zoomed in on a retina iPad (even if I am not an Apple fan, I must admit it’s a great quality screen)

  • http://soluml.com Benjamin Solum

    I’ve used a few SVG images in a few projects, but I never could justify keeping the markup inline to avoid the HTTP request. Sometimes, there’s a performance benefit to using an HTTP request and caching the element vs. leaving everything inline. Same principles apply to baase64 encoded images. I think the general rule of thumb is that if the image is larger than 2KB that it’s probably best to just leave it as an image file and have the browser cache it. This, used with proper expiry headers is very efficient.

  • http://kadrmasconcepts.com/blog/ Jason Kadrmas

    Android. 90.2% of devices are still less than < v3.

    http://developer.android.com/resources/dashboard/platform-versions.html

  • Anthony

    Great article! I’m going to start using SVG where it makes sense as opposed to canvas.

  • http://www.shaundunne.com Shaun Dunne

    What a great article. Whilst not totally covering all the pitfalls that comes with support for SVG (especially in Android) it’s certainly gone a long way to show it’s strengths. Sure, IE support is pretty poor, but I have had experience in using a library like Raphael which takes care of handling the VML for those browsers and makes building analytical graphics and graphs much easier.

    SVG might not be the be all and end all for every persons solution, but what is? If you’re currently building a mobile web app and not doing some sort of progressive enhancement by using SVGs for your icons then you are seriously loosing out – you can have a fallback for the devices that don’t support it yet (using dataURI or just plain images). If you need to draw complex UI elements, graphs or maps and your project allows for it (whether that be with time or support) then you should certainly give SVG a shot. SVG might not be the be all and end all when it comes to drawing in the browser – but it’s a good option.

  • Mickey Mouse

    Bad article, bad title.
    More about how to hit Canvas on the head.
    Canvas is not in a competition with SVG, they are both awesome options good for doing different things.
    Like everything in related domains they have overlapping areas.

    Waste of time. Sorry.

  • Potado

    Sweet! I love SVG.

  • http://www.netsi.dk/wordpress Sten Hougaard

    Hi,
    I was happy to read this article because in the information stream related to implementing stuff on the net, SVG seem to lack some focus. I for one had not been thinking about SVG for a long time. I am using a program Xara Designer Pro X (read more: http://www.xara.com) which can read and export to SVG, so being reminded that SVG support is starting to become a realistic option was great, for me.

    I also decided to do some tests and write a small blog post about it. You can read it here: http://dl.dropbox.com/u/3260327/blog/How%20do%20SVG%20Render%20on%20various%20platforms.html
    In it I have done 20 tests on various combinations of OS and browser (versions). It seems in my test that 17 out of the 20 tests I did came out with a positive result. Only MSIE7, MSIE8 and Android could not render the test SVG page I used.

    I will consider using a combination of Conditional comments tests and SVG. Perhaps also adding a javascript polyfill (like Raphael.JS) as mentioned by TOM in this thread.

    Thank You Jonathan Cutrell

    /Sten

  • JohnG

    “Why Aren’t You Using SVG?” because more than half of all people on the planet are using IE < 9. While not every web site's stats will show the same results for browsers used, such a high percentage of overall users simply must be taken into account for the vast majority of site designers/developers. Nobody likes working around IE but it's still a sad fact of life that we need to and that is not going to change significantly for at least a few more years.

  • http://www.studio.kalaam.in Abul

    I’m a SVG fanatic from the beginning…
    I’ve extensively used SVGs on my recent websites… http://kalaamcomix.in

    Also on of my sites into also uses svgs pretty well… http://www.kalaam.in

  • http://ecmanaut.blogspot.com/ Johan Sundström

    http://jsfiddle.net/ecmanaut/unFyq/130/ is a better D3 example – using d3.timer instead of setTimeout gets you full frame rate, nicely synced with requestAnomationFrame (also without effort), rather than the choppy setInterval based crap of old days.

    • Altino

      Hello I´m new to jsfiddle, and I tried to se the examples 1 and 2 and the example that you submited http://jsfiddle.net/ecmanaut/unFyq/130/ but I don´t see anything in the result panel, except the background colour.

      I should do something to see the result I don´t get it.
      Could someone help me.

  • http://ewellic.org Doug Ewell

    I think you meant to say an SVG XML document of any complexity looks relatively *arcane*, not archaic. Unless you meant that long strings of numbers separated by commas look old-fashioned, which might be true.

    • http://whiteboard.is Jonathan Cutrell
      Author

      I indeed meant archaic – but arcane is also a (perhaps even more) fitting description.

    • lo-do

      u got pwnd! and I meant pwnd!

  • Oswald
  • JohnBon

    I want to see some dynamic graph tutorials

  • http://it.knightnet.org.uk Julian Knight

    Why aren’t we using it? It’s quite simple, two reasons:

    1) There are no high-level tools available for data driven graphs (there are plenty for data-driven charts) or diagrams. D3 requires far too many manual calculations to be of much real use except in specialist circumstances.

    2) On the non data-driven side of things, the tools are too inconsistent. SVG is not integrated into common professional diagram tools such as Visio.

    I for one would love it if there were a high level tool (at least of the level of GraphViz, preferably higher-level still) for doing data-driven diagrams, I have many use cases for such a tool and I believe that it would quickly be integrated into the common web platforms (Wiki’s, blogging tools, WordPress, etc.).

  • Jeffery

    Why are you guys saying IE9 doesn’t support svg, the full spec may not be but its there, and IE10 has it and it performs really good,

    And just cause other vendors have been quick to adopt specs just to pack their browsers with tons of features in order to look better than the next guy. doesn’t mean the technology is there. svg has a long way to go. they aren’t doing you any favors by forcing you to hack through yet another incomplete, hard to work with specification

    I thought the era of just clambering to support the latest features were over. that standards meant looking for a way to ease develop time and improve performance.

    this conversation is getting old and silly.

  • http://cmoreira.net Carlos Moreira

    SVG is great. And for maps, google has a great API, the Geochart tool.
    I developed a plugin for wordpress that makes it easy to create SVG maps with the google API.
    Check it out: http://cmoreira.net/interactive-world-maps-demo/

    SVG for the win! :)

  • Isaac

    Really interesting.

    I was looking for this kind of technology to make games.
    I’ve found this tool that use SVG format in unity.

    http://www.youtube.com/watch?v=g7zTmKvvUpk

    Do you think it’s worth it?
    It looks pretty simple to use.

  • http://vanderwijk.nl Johan

    On this site I have used SVG images for the header logo and the social media icons in the footer: http://materialxperience.nl/

    The SVG images look stunning on retina displays, even when zoomed in. Unfortunately SVG images are a bit of a pain to work with, you have to make sure all pixels are aligned properly or else you get very fuzzy lines. Another issue I have come across is that on some zoom levels on the iPad some strange spaces appear between image elements. I guess this is because the iPad is rounding off half pixels.

    I am loading the images via CSS and use Modernizr to check for SVG support. This does mean I had to create fallback images for IE8 and lower.

    • http://www.facebook.com/Xereu Darwin Winston Santos Arismend

      You did a great Job with that website, I severely stretched and zoomed in on it and the logo looked brilliantly sharp every time.

  • Ryan

    You adddress your audience as if they’re retarded. Well, I guess they are.

  • Amy

    Great article! I am, as Rude Ryan noted below, “retarded” in knowledge about SVG. As a graphic designer who is tasked more and more often with creating vector images for web, however, I thought this was a fantastic introduction and it will certainly help me communicate with my developers better ;)

  • jeremy

    Hey! Any clue about how we could put some “copyright” restriction/declaration in the .svg file? Using metatag maybe?

  • thorsten

    I love SVG. In theory. I’m not using it, because I don’t want to drop the resulting xml-code in my HTML. I want to keep HTML, data (png, svg, …), and logic (.js) seperated.

    My problem was: A co-worker made example sprites with Inkscape and we wanted to animate them with Raphael, but couldn’t get the two to work together withjout workarounds. I had to use some quirky online-tool to convert my “.svg” into Raphael code, paste it into my .js-files and had to re-upload my js whenever the sprite got updated.

    That was like 12 Month ago. Is there a reliable way to keep Inkscape-SVG-Files and Raphael-code seperate without such workaround, today?

  • http://twitter.com/jquer_in jquer.in

    I had a question ..can you manipulate background svgs?

  • Wout

    Svg.js is a new lightweight library with an easy readable syntax, a lot of great features, no dependencies and only 4.5k gzipped.
    http://svgjs.com

  • MikeMarcacci

    I’m not sure the saving-a-request argument is always a valid advantage to embedded SVG – while you might see an advantage compared to an image that is used only once on a site, an external file (bitmap or SVG, for that matter) that is used on all pages, like a logo, will be cached by the browser, saving the transfer bandwidth.

    • If the file is large and reused throughout the site, then you’re better off keeping it as an external file.

    • If it’s small or a one-off image you might see some improvement by embedding SVG.

  • http://twitter.com/hardiksondagar Hardik Sondagar

    SVG Progressive Arc of given percentage number.
    Check demo here : htmltagstripper.com/svg
    And Source Code + Tutorial : http://cakephptutor.wordpress.com/2013/05/19/svg-arc-tutorial/