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.
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.