Soma Szoboszlai - codepen.io/szsoma
About the SVG
Advantages
Code & usage
Animation & optimization
Demos
Why send pixel data...
...when you can send geometry?
Original picture
Pixel based
Vector based
But there is a complexity limit
The SVG specification is an open standard developed by the W3C in 1999.
Scalable Vector Graphics is an XML-based vector image format for 2D graphics with support for interactivity and animation.
Companies including Adobe, Apple and IBM all took part in defining and creating this new image type.
(yes)
PNG - 445 Kb
SVG - 101 Kb
22.7%
<line>
<rect>
<circle>
<ellipse>
<polygon>
<poliline>
<path>
Text
<text>
<feMorphology>
<animate>
<feBlend>
<feDropShadow>
<script>
<textPath>
Inkscape
Sketch
Illustrator
<svg width="0" height="0">
</svg>
<defs>
<defs>
<g id="facebook-icon">
<g id="insta-icon">
</g>
<circle cx="60" cy="60" r="50"...>
</g>
<path d="M16,.4a16,16,0,0,0-5.1...>
<polygon points="152.1 27.1 152.1 >
<svg viewbox="0 0 100 25" class="social-icons">
</svg>
<use xlink:href="#facebook-icon"></use>
Image tag
<img src="innonic.svg" alt="Innonic Logo"
height="65" width="185">
CSS background
.logo {
background-image: url(innonic.svg);
}
Embed tag
<embed type="image/svg+xml" src="bblogo.svg" />
Object tag
<object type="image/svg+xml" data="bblogo.svg">
</object>
. . .
<body>
<link href="https://fonts.googleapis.com/css?family=Lato:900" rel="stylesheet">
[...]
<svg xmlns="http://www.w3.org/2000/svg" width="302.5" height="171.5" viewBox="0 0 302.5 171.5">
<g id="conversific">
<text transform="translate(0 163.3)" font-size="46" fill="#333332" font-family="Lato-Black, Lato">CONVERSIFIC</text>
</g>
<g id="emblema">
<path d="M250,18.4,201.9,46.2v55.6L250,129.6l48.1-27.8V46.3Zm29.1,72L250,107.3,220.9,90.5V56.8L250,40l29.1,16.8Z" transform="translate(-97.9 -18.4)" fill="#27af92"/>
<polygon points="152.1 27.1 152.1 55.2 127.8 41.2 127.8 69.3 152.1 83.3 176.4 69.3 176.4 41.2 152.1 27.1" fill="#333332"/>
</g>
</svg>
[...]
</body>
Icons
Logos
UI elements
Vector-based graphics
D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS.
Where art and code intersect
It is a very tight deadline for the browser!
Loading
DOM tree:
all elements in the document
Render tree:
Calculate styles,
animation values
Draw Calls
GPU
thread
Rendering
Painting
Displaying
Reflows:
width
margin
top
left
right
padding
etc.
Repaints:
box-shadow
color
bg-position
bg-color
border-radius
etc.
GPU Accelerated:
transform
opacity
filter*
*except for blur and drops-shadow
with left property
Repaints
with transform
No repaints
CSS/SCSS
Small sequences and simple interactions
GSAP (GreenSock)
For complex movements, sequencing
React-Motion
For single movements that you'd like to look realistic
Snap.svg
"jQuery for SVG"
etc.
Cheng Lou
27.9Kb / 6.67Kb
svg id
group id
16.7 ms bro'!
matrix()
matrix3D()
6.83Kb / 2.75Kb
5.62Kb / 3.49Kb
People are Awesome:
Sarah Drasner
Sara Soueidan
Chris Coyier
Will Boyd