A Primer to Front-end SVG Hacking

A Primer to Front-end SVG Hacking

Using SVG (Scalable Vector Graphics) on websites is a lot safer than many front-end developers think. Authoring aside — I wouldn’t suggest trying to hand-code an illustration more complex than a triangle* — the standard is well supported in browsers today and perfect for resolution independence when CSS and icon fonts aren’t suitable.

* Quick fire question: at which corner does this right-angle triangle point?

<polygon points="0,100 0,0 100,0 "/>

I’m going to walk you through many conceivable implementations:

Image Elements

Basic usage is as simple as swapping out a regular raster graphic — PNG, JPEG, or GIF — with an SVG file. Here’s an example in HTML:

<img src="image.svg">

According to the can I use compatibility table only Internet Explorer 8 and lower, and Android Browser 2 lack support. They will download and fail to render the image.

With client side fallbacks we can’t avoid the initial download. We could swap out the element source with JavaScript if there’s an error:

<img src="image.svg" onerror="this.onerror=null; this.src='image.png'">

That’s cute but I can’t imagine many circumstances where it would be the best solution. You can achieve similar results with feature detection:

if (!Modernizr.svg) {
        $(this).attr('src', $(this).attr('src').replace('.svg', '.png'));

Readmore: http://dbushell.com/2013/02/04/a-primer-to-front-end-svg-hacking/

Alternative : Also Read this

9 Apps Built by Self-Taught Coders

You can access plenty of service online when learning to code: Codecademy, Skillshare, Treehouse, Code School, Learn Code The Hard Way, Udemy, General Assembly, Udacity and the list goes on. Some charge per class or by monthly membership, while others are free or accept donations.

But still, learning anything outside traditional education requires personal initiative. For many people, it will involve setting aside time outside of a regular day job in which you do something other than programming. But as our world is more and more influenced by what we’re able to accomplish with code, being a maker of such programs gives a person an advantage in nearly any industry.

Read more