It would be amazing to be able to load an SVG icon as an image with a class, and then be able to use CSS to manipulate the image (change the colour etc) but know the image is cached by the browser.
It would be amazing to be able to load an SVG icon as an image with a class, and then be able to use CSS to manipulate the image (change the colour etc) but know the image is cached by the browser.
<svg><use xlink:href='#svg-id'></use></svg>
Here's a quick example I threw together: http://syd.jjcm.org/svgCacheTestIf you click on the folder icon you can see it being changed by the css.
If you inline using JS, you can use standard styling / classes to modify the display. Since it happens via standard browser requests, you get normal caching behaviour. One bad thing though is that you have to wait for the JS to execute, so there may be some blinking.
I bet you could do some kludgey stuff to get it to load. An idea that springs to mind is to include your svg as an image in the page (but hidden, like a sprite map) and then use the 'use' tag referencing ids in the hidden image wherever you wanted to place the sprites.
Either way, you currently have to work around a (seemingly arbitrary) restriction with browsers not allowing CSS on svg images.