I'm writing a single HTML page in plain vanilla JS, HTML, and CSS.
Everything so far is fine but I now need to include the same SVG icon in four different places.
Code duplication is bad and if I were using something like React I'd just make it into a component and use that in each of the four places.
Since I'd prefer to stay vanilla and not use any external libraries I took a look at Web Components but they seem like they're a bit of a failed experiment with somewhat limited browser support.
Something that would probably work is just returning a raw string of the HTML contents from a JavaScript function and then using JavaScript again to inject that node into each of the four elements, but that seems very cumbersome and messy.
Is there something obvious that I'm missing here? I'm just looking for a way to include this SVG in four separate locations without copying and pasting the duplicate code in each location, as that is verbose and error-prone. I also do not want to include a build step or process for this simple change.
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-minimize-2">
<polyline points="4 14 10 14 10 20"></polyline>
<polyline points="20 10 14 10 14 4"></polyline>
<line x1="14" y1="10" x2="21" y2="3"></line>
<line x1="3" y1="21" x2="10" y2="14"></line>
</svg>

<svg-icon>component at iconmeister.github.io FYI, Code Duplication is actually very good, minified size does NOT count because GZip/Brotli very much like duplications. So from a download time perspective, and if you actually just want 4 static SVGs, then use 4 static SVGs