4 ms·
One way to do it is to have an external file with all your svg data that you append to the dom afterwards. Wherever you want to use a svg, just reference the ap
by jjcm 10y ago
One way to do it is to have an external file with all your svg data that you append to the dom afterwards. Wherever you want to use a svg, just reference the appended svgs:
<svg><use xlink:href='#svg-id'></use></svg>
Here's a quick example I threw together: http://syd.jjcm.org/svgCacheTest http://syd.jjcm.org/svgCacheTest
If you click on the folder icon you can see it being changed by the css.
- rrrx3 10y agoThanks for posting this - I had been running into the same issues above.
- iamben 10y agoInteresting, thanks. Alas I think this solution still has its drawbacks in that you can't target classes within the SVG. Example: https://css-tricks.com/svg-use-with-external-reference-take-2/ https://css-tricks.com/svg-use-with-external-reference-take-...