Comments (2)
To fix your problem, you would change the code to look more like this:
var miniSvgDataUri = require("mini-svg-data-uri");
var svg = '<svg version="1.1" id="level1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 16 20" xml:space="preserve"><style>.st0{fill:#020203}.st1{fill:#010202}</style><path class="st0" d="M16 4v15c0 .6-.4 1-1 1H1c-.6 0-1-.4-1-1V4c0-.6.4-1 1-1h2v1H1v15h14V4h-2V3h2c.6 0 1 .4 1 1z"/><path class="st0" d="M10 2c0-1.1-.9-2-2-2S6 .9 6 2H4v3h8V2h-2zM3.7 7H14v1H3.7z"/><circle class="st1" cx="2.6" cy="7.5" r=".6"/><path class="st0" d="M3.7 16H14v1H3.7z"/><circle class="st1" cx="2.6" cy="16.5" r=".6"/><g><path class="st0" d="M3.7 10H14v1H3.7z"/><circle class="st1" cx="2.6" cy="10.5" r=".6"/></g><g><path class="st0" d="M3.7 13H14v1H3.7z"/><circle class="st1" cx="2.6" cy="13.5" r=".6"/></g></svg>';
var optimizedSVGDataURI = miniSvgDataUri(svg);
Youβre not the only person to be confused by the different function names (see #12), so clearly I should update the readme.
By the way, your SVG could be optimized even better by running it repeatedly through SVGOMG first. That would make your input to this tool look like:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 20"><path d="M16 4v15c0 .6-.4 1-1 1H1c-.6 0-1-.4-1-1V4c0-.6.4-1 1-1h2v1H1v15h14V4h-2V3h2c.6 0 1 .4 1 1z" class="st0"/><path d="M10 2c0-1.1-.9-2-2-2S6 .9 6 2H4v3h8V2h-2zM3.7 7H14v1H3.7z" class="st0"/><circle cx="2.6" cy="7.5" r=".6" class="st1"/><path d="M3.7 16H14v1H3.7z" class="st0"/><circle cx="2.6" cy="16.5" r=".6" class="st1"/><path d="M3.7 10H14v1H3.7z" class="st0"/><circle cx="2.6" cy="10.5" r=".6" class="st1"/><path d="M3.7 13H14v1H3.7z" class="st0"/><circle cx="2.6" cy="13.5" r=".6" class="st1"/></svg>
And you could remove the class
attributes to make it even smaller!
from mini-svg-data-uri.
Thank you very much, now I got it!
from mini-svg-data-uri.
Related Issues (14)
- Could we get an online version hosted on GitHub pages? HOT 6
- Incorrect function name referenced in example? HOT 3
- Why single quotes? HOT 3
- Feature request: usable via command line HOT 4
- Should this work in a cursor as well? HOT 3
- Works in link only after pressing Enter HOT 4
- Broken image example HOT 1
- Going the other direction HOT 2
- CLI usage example in README.md incorrect (typo?) HOT 2
- Compact version HOT 2
- Shorter color names don't check the entire hexcode HOT 11
- Feature request: files -> SASS variables HOT 1
- Not compatible in srcset attribute HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mini-svg-data-uri.