• Stars
    star
    142
  • Rank 257,064 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An experimental tool that turns a folder of SVG files into a single SVG Stack

SVG Stacker

An experimental tool that turns a folder of SVG files into a single SVG Stack. It also creates some demo HTML files that use the stack with different embedding-techniques (iframe, embed, img, object, background-image).

SVG Stacker is based on NODE.js.

The project contains three example stacks based icons of the famous Tango Icon Library, the popular Iconic icon set by P.J. Onori and files from wikipedia.

I created SVG Stacker to explore the power of the SVG Stack concept and test filesize, performance and browser-support.

Installation & Usage

npm install svg-stacker -g
svg-stacker -s SOURCE_DIR -t TARGET_DIR

Example Stacks

with Webkit fix:

About SVG Stacks

Simon 'Simurai' first described 'SVG Stacks' in March 2012. It's a technique to stack different SVG objects into one file to save HTTP Requests.

First we give each of our icons in the SVG file a unique ID and the same class name, add some CSS to hide all icons and only display the one that gets selected with :target. And now we can use a hash in the URL to pass the ID into the SVG file, like background: url(icon.svg#ID).

Read Simons blog post. Simon also created a SVG Stack demo that works pretty well in Firefox, but not yet in Webkit, see (Webkit-Bug).

The ':target'-technique was first introduced by @erikdahlstrom – it's worth checking out his SVG Code snippets.

Webkit Fix

Read annotated source.

Background

We decided to work with SVG for a recent mobile website project. It is an open standard, it is widly supported by browsers and leads to great visual results, especially when it comes to devices with different pixel densities.

"SVG-Stacks are the new Imagesprites." – Are they?

There are pros and cons. Here is a list of things we thought about so far and would like to discuss:

  1. Support for colors

    compared to monocromatic icons, that can be easily embedded with Webfonts

  2. Easier to write and read in CSS

    button.cart {
      background: transparent url(stack.svg#cart) no-repeat top left;
    }
    

    compared to

    [data-icon]:before {
        font-family: 'IcoMoon';
        content: attr(data-icon);
    }
    <a href="#" class="button-with-icon" data-icon="+">Add</a>
    

    Webfont icon embed

    Webfonts are great for monochrome icons. Icomoon is a great tool to define icon sets and add custom svg objects. One could argue that they causes some semantic issues as they always produce content (compared to decorative background-image), which might be OK when using Unicodes Private Use Area.

    But for Developers it might feel more natural to work with SVG Stacks as

  3. SVG Stacks behave like raster-images

    <img src="stack.svg#flowers">
    

    They can be treat in HTML and CSS like we used to treat raster images.

  4. Animation

    See soccer-ball in Wikipedia Example

  5. (Not) yet available on Webkit

    There is a Webkit-Bug that needs to be fixed to make SVG Stacks work.

    Update For now I created a jQuery Plugin to fix SVG Stacks for Webkit. See Webkit Fix above.

  6. Slow?

    Test the examples: Some browser need an extensive rendering time.

More Repositories

1

data-populator

A plugin for Sketch and Adobe XD to populate your design mockups with meaningful data. Goodbye Lorem Ipsum. Hello JSON.
JavaScript
1,668
star
2

sketch-bounding-boxer

Toggle visibility of 'boundingBox' layers in a Sketch document
63
star
3

SVG-Cleaner

A tool for cleaning SVG Files - partial port of Scour to JavaScript.
JavaScript
38
star
4

sketch-aspect-ratio

A simple plugin to apply preset or custom aspect ratios to a selected layer.
JavaScript
32
star
5

sketchapp-driver

Sketch Driver is a node module to 'drive' Sketch App from javascript.
JavaScript
30
star
6

design-studio-tools

a growing collection of tools we use at precious
Shell
21
star
7

design-studio-kit

Why we do design studio, how we do it, what we learned so far & the material we use.
15
star
8

shades-of-bootstrap

An experimental approach to bootstrap customization
JavaScript
9
star
9

slidedeck-pdf.js

Experimental slidedeck viewer based on pdf.js: it renders Apple Keynote exported PDFs with speaker notes in the browser, extracts and cuts off the notes and displays them as HTML.
JavaScript
7
star
10

skills-not-position

A design study: People rate skills and statements to find their perfect job position.
JavaScript
4
star
11

sketch-scale-artboards

A very simple Sketch plugin to scale multiple Artboards to the same size.
4
star
12

css-sandbox-setter

makes it easy to setup a CSS Sandbox, a place where to experiment with CSS (OS X only)
2
star
13

rename-fonts.com-download-kit-webfonts

a tool to apply semantic file names to webfonts included in fonts.com self-host download kits
JavaScript
2
star
14

designtools-hackday-visual-creator

JavaScript
1
star
15

docdoc-generator

A static documentation generator. Like jekyll, but single purpose + media files
JavaScript
1
star
16

docdoc-theme-cards

An improved theme for docdoc
CSS
1
star
17

grunt-gss

Save your Google Spreadsheets as CSV or JSON.
JavaScript
1
star
18

sketch-artboard-name-to-layer-name

exporting layers to folder and subfolder (specified in the artboard name)
1
star