npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dunks1980/inline.svg

v1.3.7

Published

A simple plugin that inlines a SVG file in your HTML

Downloads

70

Readme

inline.svg

A simple way to render a SVG file into a HTML document so styling and js can be applied to it.

Demo

Install

npm i @dunks1980/inline.svg --save
import {inlinesvg} from "@dunks1980/inline.svg";

Usage

New in version 1.2.0 - better for caching and wrapping with an anchor:

<use class="svg" href="svg/foo.svg"></use> 
<use class="svg" href="svg/bar.svg"></use> 

New in version 1.3.0 - You can use any type of file extension as long as the contents are valid HTML, this can be used to inline HTML elements including script tags and not just SVG's:

<use class="somehtml" href="svg/foo.html"></use> 
<use class="somephp" href="svg/bar.php"></use> 

Or old way:

<a class="svg" href="svg/foo.svg"></a>
<a class="svg" href="svg/bar.svg"></a>

Then call this function in your JS, it will attempt to convert all tags it finds with that selector:

inlinesvg('.svg');

This replaces the <use></use> or <a></a> tags with the SVG file contents, inlined in the document.

A Callback is available for after adding the SVG's:

inlinesvg('.inlinesvg', (elements) => {
  console.log(elements);
});

With the url of the the SVG loaded and data attribute for identifying them:

// console.log(elements);
▼ (4) [{…}, {…}, {…}, {…}]
▶ 0: {url: "http://localhost:1234/svg/logo.svg", data-inlinesvg: ".inlinesvg-1", element: false}
▶ 1: {url: "http://localhost:1234/svg/npm.svg", data-inlinesvg: ".inlinesvg-2", element: false}
▶ 2: {url: "http://localhost:1234/svg/github.svg", data-inlinesvg: ".inlinesvg-3", element: false}
▶ 3: {url: "http://localhost:1234/svg/email.svg", data-inlinesvg: ".inlinesvg-4", element: false}
▶ length: 4
▶ __proto__: Array(0)

Passing true after the callback returns the elements for JS usage if needed:

inlinesvg('.inlinesvg', (elements) => {
  console.log(elements);
}, true);
// console.log(elements);
▶ 0: {url: "http://localhost:1234/svg/logo.svg", data-inlinesvg: ".inlinesvg-1", element: a}
▶ 1: {url: "http://localhost:1234/svg/npm.svg", data-inlinesvg: ".inlinesvg-2", element: a}
▶ 2: {url: "http://localhost:1234/svg/github.svg", data-inlinesvg: ".inlinesvg-3", element: a}
▼  3:
  data-inlinesvg: ".inlinesvg-4"
  ▼ element: a
      accessKey: ""
      ariaAtomic: null
      ariaAutoComplete: null
      ariaBusy: null
      ariaChecked: null
      ariaColCount: null
      ariaColIndex: null
      ariaColSpan: null

New in version 1.3.1 Passing data to inlined content:

index.html

<use id="html" href="html/example.html"></use>

html/example.html

<div class="{{classname}}">
  <p>{{line1}}</p>
  <p>{{line2}}</p>
  <p>{{line3}}</p>
  <p>{{line4}}</p>
</div>
inlinesvg('#html', {
  classname: `my-class`,
  line1: `npm i @dunks1980/inline.svg --save`,
  line2: `import {inlinesvg} from "@dunks1980/inline.svg";`,
  line3: `&lt;use id="svg" href="/foo.svg"&gt;&lt;/use&gt;`,
  line4: `inlinesvg('#svg');`
});

Results in the following rendered in index.html:

<div class="my-class">
  <p>npm i @dunks1980/inline.svg --save</p>
  <p>import {inlinesvg} from "@dunks1980/inline.svg";</p>
  <p>&lt;use id="svg" href="/foo.svg"&gt;&lt;/use&gt;</p>
  <p>inlinesvg('#svg');</p>
</div>