How to use mini-svg-data-uri - 2 common examples

To help you get started, we’ve selected a few mini-svg-data-uri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keplergl / / src / utils / dom-to-image.js View on Github external
.then(nd => {
      nd.setAttribute('xmlns', '');
      const serializedString =  new window.XMLSerializer().serializeToString(nd);

      const xhtml = escapeXhtml(serializedString);
      const foreignObject = `<foreignObject x="0" y="0" width="100%" height="100%">${xhtml}</foreignObject>`;
      const svgStr = `<svg xmlns="" width="${width}" height="${height}">${foreignObject}</svg>`;

      // Optimizing SVGs in data URIs
      // see
      // the best way of encoding SVG in a data: URI is data:image/svg+xml,[actual data].
      // We don’t need the ;charset=utf-8 parameter because the given SVG is ASCII.
      return svgToMiniDataURI(svgStr);
github Andarist / data-uri.macro / src / index.js View on Github external
const getDataUri = filePath => {
  if (path.extname(filePath).toLowerCase() === '.svg') {
    const file = fs.readFileSync(filePath, 'utf-8')
    return svgDataUri(file)

  const file = fs.readFileSync(filePath)
  return `data:${mimeLookup(filePath)};base64,${new Buffer(file).toString(


Small, efficient encoding of SVG data URIs for CSS, HTML, etc.

Latest version published 9 months ago

Package Health Score

71 / 100
Full package analysis

Popular mini-svg-data-uri functions