So I would like to do the same, or similar, to what I would do in HTML:
<picture>
<source type="image/webp" srcset="my-image.webp">
<img src="my-image.jpg">
</picture>
But, obviously this won't work:
<svg>
<picture>
<source type="image/webp" srcset="my-image.webp">
<img src="my-image.jpg">
</picture>
</svg>
I could use .htaccess approach, but I would prefer not to because of the 302 HTTP redirect.
The solution also needs to work without any JavaScript trickery...