@tonis2/svg-load

1.0.0 • Public • Published

svg-load

Small ES6 SVG loader as Custom Element.

Usage

Install

npm i --save svg-load;

Register

import svg from "svg-load";

customElements.define("svg-el", svg);

Props

  • src - svg element source.

Example

After registering the element in javascript you can use <svg-el src="/images/mysvg.svg"> in your html.

Working example

Why ?

Because loading a SVG that is easily editable with css and javascript is still pretty painful, and i don't want to rely on React or Jquery to load my SVG.

No dependencies, only native javascript means more clearer code and smaller package size.

Hopefully Web Components will get more popular as time goes on, its still not supported on all browsers but can be polyfilled.

More about Web Components

Package Sidebar

Install

npm i @tonis2/svg-load

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • tonis2