SVG file JavaScript didn’t work as image?
The SVG JavaScript didn’t work
The svg file that I got was quite big and had written JavaScript in it. When I used that svg file as an image source like below:
<img src="path-to-file.svg">
It simply rendered the image and the JavaScript that was written in it didn’t work.
What solved it?
I had to render the image as svg and then all the JavaScript written in it worked as expected.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 19" id="bell" width="100%" height="100%"><path fill-rule="evenodd" d="M15.91 11.594l-.536-1.268-2.211-1.163-.14-.328-1.051-2.484c-.881-2.085-2.836-3.38-4.964-3.33l-.528.012-.305-.432c-.381-.538-1.06-.745-1.627-.503-.568.242-.89.876-.768 1.522l.097.52-.374.374C1.99 6.02 1.56 8.333 2.442 10.414l1.192 2.816-.702 2.406.534 1.262 12.444-5.304zm-2.192 3.104a3.868 3.868 0 0 1-2.325 3.953 3.84 3.84 0 0 1-4.446-1.068l-3.015 1.285a1.651 1.651 0 0 1-2.168-.887l-.94-2.221.702-2.406-.913-2.157C-.52 8.526-.053 5.537 1.767 3.454 1.725 2.09 2.494.804 3.77.26c1.276-.545 2.73-.207 3.682.77 2.755.128 5.22 1.868 6.35 4.54l.913 2.156 2.211 1.163.138.328.803 1.897a1.67 1.67 0 0 1-.869 2.185l-3.28 1.399zm-2.028.864l-2.715 1.157a1.853 1.853 0 0 0 2.715-1.157z"></path></svg>
Tool to reduce the big svg file
https://jakearchibald.github.io/svgomg/
Useful URLs about SVG
https://svgontheweb.com/