I have huge dynamic lists that refer to a large amount of seperate (generated) SVGs (stylized acronyms).
I do not like to put the the generated SVGs in seperate files, because it will create hundreds/thousands of requests. Even with HTTP/2 somehow I would not like this solution. I have the feeling it creates unnecessary overhead.
Everytime inlining the full SVG I also do not like. It creates duplicate data for all the same acronyms (an item can appear multiple times at the page) and next to that it is a highly dynamic page: I have the feeling changing a background image is a lot faster then changing the DOM with the SVG.
So: is it possible to refer to a SVG defined somewhere else in the document?
I'm looking for something similar to:
<!-- generated by server -->
<div style="display: hidden;">
<svg id="acronym-abc">
[...]
</svg>
<svg id="acronym-xyz">
[...]
</svg>
</div>
<!-- generated by client -->
<ul>
<li style="background: SVG(id=acronym-abc)"></li>
<li style="background: SVG(id=acronym-xyz)"></li>
<li style="background: SVG(id=acronym-abc)"></li>
[...]
</ul>
UPDATE
It was not clear from my question, but I have the preference for something that I can use in combination with background-image
and support for IE9. Otherwise I'll accept the answer from @web-tiki.