Dynamically insert SVGs directly into the dom.
Place the path to the svg within the data attribute.
<div class="my-class" data-svg="img/cta.svg"></div>
Call the function on your class.
insertSvg('.my-class');
By default the svg is inserted within the node. To instead replace the node with the svg add the replace
class to the element. All element classes are preserved.
<div class="my-class replace" data-svg="img/cta.svg"></div>