{"name":"mini-svg-data-uri","version":"1.4.4","description":"Small, efficient encoding of SVG data URIs for CSS, HTML, etc.","main":"index.js","types":"index.d.ts","bin":{"mini-svg-data-uri":"cli.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":"00dc78c8f77eb7b47299a9e3d564749105810c9c","_id":"mini-svg-data-uri@1.4.4","_nodeVersion":"14.8.0","_npmVersion":"7.12.0","dist":{"integrity":"sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==","shasum":"8ab0aabcdf8c29ad5693ca595af19dd2ead09939","tarball":"http://registry-npm.ywwl.com/mini-svg-data-uri/download/mini-svg-data-uri-1.4.4.tgz","fileCount":8,"unpackedSize":10460,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKSR3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmooSA/9GGkzX6n+W4tHZfWD41k4vBJtYyQ+2QrPa3Ao5zJIwjUBrHK6\r\njxFyeP5QZGZunLlALxy0O5xftTGTY5I5EPiGD/GPTHv+yjkZYLdx1cDshGSc\r\nyhPFhDFF6tcC9PjPkMA5cUCNU+hacKckgOJHgz4CpNGH4MOXFfg2DsPoNvWb\r\nC523oK3bkL/WEMQAmUoUMIDBubkoCKxjXfpShCrx/J05sEN4oiS1k64WNH85\r\n2Ng1f6kwZmASyNO6hbBr6CtnUmerxGZGRelGoH3cfWmTK5SUEzsSvJqRe0Sl\r\nH/1e3ADaSoWcjvHFScCnoITWZN4apOoZvRdxhWjAHKD67UNz7NdCLyLS/Gws\r\niEYoWkEETwncvJY8bVjSjkbBDhGF4FAEWlxllk1+8xAi5iinMB4fKZ2TcPdV\r\nqMmZVuwoAUawzm/aESEmXp58DOaICvdPErR9+EBKFruEEql+QmFqGNT5b5Zh\r\nivPsWnt22Bd50k/M3zkv2C5y21yhuSlP2O603pvTTOylyaXvk/uYJw4O3qvm\r\nTCH82mrf3FkfoxbhVsI7hkqJDaM8NauQFX5YcuvC+n8NWFiQXg3nFnl5ZDrd\r\n9Wgd26Hj684d0scBqkzlaAMFHUCy7srSf/ZAIzXU4xJ27ZV6NEMKfrggZHj/\r\n2Z9tMguUpRkVg9Dh0t1gFE9ZnVR7m1Nob4Q=\r\n=FrEn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkSsIlm51eU+LiWKcKGbg+xdym5lzoXnbNIskGbIWoVwIhALU8dP5ZFPw2Dvuy39kP2RX3N9aXnmeyyjKr4u5jSTlA"}],"size":4912,"noattachment":false,"key":"/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz"},"_npmUser":{"name":"tigt","email":"npm@ti.gt"},"directories":{},"maintainers":[{"name":"tigt","email":"npm@ti.gt"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mini-svg-data-uri_1.4.4_1646863479090_0.5585998240841532"},"_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":1646863479258,"_cnpm_publish_time":1646863479258,"dist-tags":{"latest":"1.4.4"}}