{"name":"mini-svg-data-uri","version":"1.0.2","description":"Small, efficient encoding of SVG data URIs for CSS, HTML, etc.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/tigt/mini-svg-data-uri.git"},"keywords":["svg","url","data","uri","minification","url encoding"],"author":{"name":"Taylor “Tigt” Hunt","email":"holla@ti.gt","url":"https://ti.gt/"},"license":"MIT","bugs":{"url":"https://github.com/tigt/mini-svg-data-uri/issues"},"homepage":"https://github.com/tigt/mini-svg-data-uri#readme","gitHead":"19f716b29b38c3711dab543cf646d77d731865cd","_id":"mini-svg-data-uri@1.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.9.0","_npmUser":{"name":"tigt","email":"npm@ti.gt"},"dist":{"integrity":"sha512-3bDQR0/DIws7pkqi/dhtmv5BGgTT2HPRzq9fos3Jz4Xc9bVnn5eC6jBb4mK25Jdt8UclKeRhateLLTz9J2Wwug==","shasum":"c4efdb71499249e02160a53db99d2eacf4b5a5c7","tarball":"http://registry-npm.ywwl.com/mini-svg-data-uri/download/mini-svg-data-uri-1.0.2.tgz","fileCount":5,"unpackedSize":8287,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb/D7jCRA9TVsSAnZWagAA9oMP/jaS99j0XT6s6PBlFMxh\ndnF8RvZFAarKtkfI0Wyq7rkPOBSu26bIKnb5PetGXz79NUR0eKpbMV/msbCk\nLECUREf3QJcd7BOhRDWSibK2t+EhXQdtU5ziUSaFrznYIRG2YgUulH50qMnm\nB2QzaQfOs6KG6eFvSUH6wkJIg6T9WhfdP+p0+klyKPCkmpf0xhJboWwMaVFy\n7UnK5sj4sw+R9SV3VyVRMn2kU22WrPpz1WcTRQ5DxeOnIBcx8venm1aSYqmi\nRrojfvaar6cZ6RSk6cco6+LFGVexrv+4s28JAitIBpaXavpzrp4LZqh5dfK+\nmZFhw2o9rlflW7/vhRDlot+G640uJlUolG7jxh3sNgjFTeM1At7gJGlgStNP\nECru2/3kJOGrIGG1khDru6vrZAwwmmU8B9PdEcxnYNhggu9RLqQK6x3ST6Hr\nZwIZ94uZVg1fLFkB49x52ZaZvQohfKjqJY2krOylSvQqWmyFp7WPC9A+nAh6\nMZiAR4OmqOWhVI6/etRLJVHoxY2XGNLC7JHWYxexcyNE5j8machi1fLtEa9p\nGKFjoWya7OJOa1NlsuA2/wnvNl7bxaNsfmO+vYwTVXm1G6uW5OO0j1ZhiDuN\nm9ZbtUXySGGalfCphUgE/MCiQtQsfAvRghhyydVJWItRDWEwAMpyTHKfyPS1\n1/4g\r\n=wjHB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWvRnQD0PPC9KsLUAxz6piWu/k4EGnEWsj5UmKhH4GkwIhANf8H07a1uCcavZUbY2a4fUeQVt1NdTVk5Qjo9QEYPjm"}],"size":4116,"noattachment":false,"key":"/mini-svg-data-uri/-/mini-svg-data-uri-1.0.2.tgz"},"maintainers":[{"name":"tigt","email":"npm@ti.gt"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mini-svg-data-uri_1.0.2_1543257826691_0.10790881460614532"},"_hasShrinkwrap":false,"readme":"Mini SVG `data:` URI\n====================\n\nThis tool converts SVGs into the most compact, compressible `data:` URI that SVG-supporting browsers tolerate. The results look like this (169 bytes):\n\n```url\ndata:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50'\n%3e%3cpath d='M22 38V51L32 32l19-19v12C44 26 43 10 38 0 52 15 49 39 22 38z'/%3e\n%3c/svg%3e\n```\n\nCompare to the Base64 version (210 bytes):\n\n```url\ndata:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIH\nZpZXdCb3g9IjAgMCA1MCA1MCI+PHBhdGggZD0iTTIyIDM4VjUxTDMyIDMybDE5LTE5djEyQzQ0IDI2ID\nQzIDEwIDM4IDAgNTIgMTUgNDkgMzkgMjIgMzh6Ii8+PC9zdmc+\n```\n\nOr the URL-encoded version other tools produce (256 bytes):\n\n```url\ndata:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%\n2F2000%2Fsvg%22%20viewBox%3D%220%200%2050%2050%22%3E%3Cpath%20d%3D%22M22%2038V51\nL32%2032l19-19v12C44%2026%2043%2010%2038%200%2052%2015%2049%2039%2022%2038z%22%2\nF%3E%3C%2Fsvg%3E\n```\n\nFor a more realistic example, I inlined the icons from the [Open Iconic](https://useiconic.com/open) project into CSS files with the 3 above methods:\n\n| Compression | Base64    | Basic %-encoding | `mini-svg-data-uri` |\n|-------------|----------:|-----------------:|--------------------:|\n| None        | 96.459 kB | 103.268 kB       | 76.583 kB           |\n| `gzip -9`   | 17.902 kB | 13.780 kB        | 12.974 kB           |\n| `brotli -Z` | 15.797 kB | 11.693 kB        | 10.976 kB           |\n\nRoughly 6% smaller compressed, but don't write off the ≈20% uncompressed savings either. [Some browser caches decompress before store](https://blogs.msdn.microsoft.com/ieinternals/2014/10/21/compressing-the-web/), and parsing time/memory usage scale linearly with uncompressed filesize.\n\n\nUsage\n-----\n\n```js\nvar svgToMiniDataURI = require('mini-svg-data-uri');\n\nvar svg = '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 50 50\"><path d=\"M22 38V51L32 32l19-19v12C44 26 43 10 38 0 52 15 49 39 22 38z\"/></svg>';\n\nvar optimizedSVGDataURI = svgToMiniDataURI(svg);\n// \"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50'%3e%3cpath d='M22 38V51L32 32l19-19v12C44 26 43 10 38 0 52 15 49 39 22 38z'/%3e%3c/svg%3e\"\n```\n\nYou can also [try it in your browser at RunKit](https://npm.runkit.com/mini-svg-data-uri).\n\n### CLI\n\nIf you have it installed globally, or as some kind of dependency inside your project’s directory:\n\n```sh\nmini-svg-data-uri file.svg # writes to stdout\nmini-svg-data-uri file.svg file.svg.uri # writes to the given output filename\n```\n\nUse `--help` for more info.\n\n### Warning\n\n* This **does not optimize the SVG source file**. You’ll want [svgo](https://github.com/svg/svgo) or its brother [SVGOMG](https://jakearchibald.github.io/svgomg/) for that.\n\n* The default output **does not work inside `srcset` attributes**. Use the `.toSrcset` method for that:\n\n  ```js\n  var srcsetExample = html`\n  <picture>\n    <source srcset=\"${svgToMiniDataURI.toSrcset(svg)}\">\n    <img src=\"${svgToMiniDataURI(svg)}\">\n  </picture>`;\n  ```\n\n* The resulting Data URI should be wrapped with double quotes: `url(\"…\")`, `<img src=\"…\">`, etc.\n\n* This might change or break SVGs that use `\"` in character data, like inside `<text>` or `aria-label` or something. Try curly quotes (`“”`)  or `&quot;` instead.\n\n\nFAQ\n---\n\n### Don’t you need a `charset` in the MIME Type?\n\n`charset` does nothing for Data URIs. The URI can only be the encoding of its parent file — it’s included in it!\n\n### Why lowercase the URL-encoded hex pairs?\n\nIt compresses slightly better. No, really. Using the same files from earlier:\n\n| Compression | Uppercase (`%AF`) | Lowercase (`%af`) |\n|-------------|------------------:|------------------:|\n| `gzip -9`   | 12.978 kB         | 12.974 kB         |\n| `brotli -Z` | 10.988 kB         | 10.976 kB         |\n\nI did say *slightly*.\n\n\nBrowser support\n---------------\n\n* Internet Explorer 9 and up, including Edge\n* Firefox, Safari, Chrome, whatever else uses their engines\n* Android WebKit 3+\n* Opera Mini’s server-side Presto\n","publish_time":1543257826773,"_cnpm_publish_time":1543257826773,"dist-tags":{"latest":"1.4.4"}}