{"id":40932485,"url":"https://github.com/tigt/mini-svg-data-uri","last_synced_at":"2026-01-22T04:11:43.003Z","repository":{"id":45068878,"uuid":"115453488","full_name":"tigt/mini-svg-data-uri","owner":"tigt","description":"Small, efficient encoding of SVG data URIs for CSS, HTML, etc.","archived":false,"fork":false,"pushed_at":"2024-05-16T11:07:20.000Z","size":26,"stargazers_count":327,"open_issues_count":1,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-01-19T05:55:53.270Z","etag":null,"topics":["data-uri","encoding","svg","url-encoding"],"latest_commit_sha":null,"homepage":"https://npm.runkit.com/mini-svg-data-uri","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tigt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-26T20:42:15.000Z","updated_at":"2026-01-14T23:42:33.000Z","dependencies_parsed_at":"2024-05-16T12:29:48.282Z","dependency_job_id":"5957c668-4daa-4ae1-b490-947a0bc7e11a","html_url":"https://github.com/tigt/mini-svg-data-uri","commit_stats":{"total_commits":22,"total_committers":8,"mean_commits":2.75,"dds":"0.40909090909090906","last_synced_commit":"00dc78c8f77eb7b47299a9e3d564749105810c9c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tigt/mini-svg-data-uri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigt%2Fmini-svg-data-uri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigt%2Fmini-svg-data-uri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigt%2Fmini-svg-data-uri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigt%2Fmini-svg-data-uri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tigt","download_url":"https://codeload.github.com/tigt/mini-svg-data-uri/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigt%2Fmini-svg-data-uri/sbom","scorecard":{"id":885115,"data":{"date":"2025-08-11","repo":{"name":"github.com/tigt/mini-svg-data-uri","commit":"09cf694678a1522d8c49aba0b0c80440dc94836e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":3,"reason":"Found 7/20 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 19 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T09:43:00.201Z","repository_id":45068878,"created_at":"2025-08-24T09:43:00.202Z","updated_at":"2025-08-24T09:43:00.202Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28590756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T00:01:37.455Z","status":"ssl_error","status_checked_at":"2026-01-19T23:58:17.328Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-uri","encoding","svg","url-encoding"],"created_at":"2026-01-22T04:11:42.937Z","updated_at":"2026-01-22T04:11:42.994Z","avatar_url":"https://github.com/tigt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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 = '\u003csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 50 50\"\u003e\u003cpath d=\"M22 38V51L32 32l19-19v12C44 26 43 10 38 0 52 15 49 39 22 38z\"/\u003e\u003c/svg\u003e';\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  \u003cpicture\u003e\n    \u003csource srcset=\"${svgToMiniDataURI.toSrcset(svg)}\"\u003e\n    \u003cimg src=\"${svgToMiniDataURI(svg)}\"\u003e\n  \u003c/picture\u003e`;\n  ```\n\n* The resulting Data URI should be wrapped with double quotes: `url(\"…\")`, `\u003cimg src=\"…\"\u003e`, etc.\n\n* This might change or break SVGs that use `\"` in character data, like inside `\u003ctext\u003e` or `aria-label` or something. Try curly quotes (`“”`)  or `\u0026quot;` 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigt%2Fmini-svg-data-uri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftigt%2Fmini-svg-data-uri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigt%2Fmini-svg-data-uri/lists"}