0

I have been experimenting with SVG paths which I use for CSS clipping. I finally got the hang of it. I make some graphic with Adobe Illustrator, then I put the SVG in the HTML with width and height of 0 and wrap the path with <clipPath> and assign it an ID to use in the clip-path property. My question is: where should I store all my SVGs so I can assign them some IDs. Putting them in the HTML doesn't seem like a good practice, especially if I have to use more than one. I haven't been able to externally load them with all the markup.

1 Answers1

0

I've heard some devs place elements in a <div id="ninja" hidden></div> element. This is for those elements that you want on the page but don't want to be rendered.

You can also use AJAX to download svg files when needed/later and embed it onto the page if you feel that it bloats up your HTML file size.

I haven't used svg clip-paths, even though I have read about them. But if you use svg files only for clip path functionality, then you can save the clip path code in an xml file, ajax request it, and, with a bit of verbose javascript, dynamically load it onto the page (Stackoverflow Question on how to do what I just said).

And for the fun of it, check out svgjs.dev

wout
  • 2,477
  • 2
  • 21
  • 32
Kitanga Nday
  • 3,517
  • 2
  • 17
  • 29