SVG images can contain JavaScript - https://news.ycombinator.com/item?id=39079943 - Jan 2024 (50 comments)
Depending on your use cases and complexity though, sometimes it's better to render to canvas instead (usually for performance reasons). JS and WASM are way more optimized than SVG is, so sometimes it's better to do the heavy calcs and then render raw pixels, instead of relying on SVG geometries.
Still though, I think this was a mistake to do.
Hopefully scripts are disabled when including svg via an img tag.
In other words, if I can set an SVG file as the image of an img tag or as the URL in a background-image style property, then I ought to be able to use an HTML file, too— and JS should run in both or neither, with the same sandbox properties. Probably neither.
Likewise, if I can set an HTML file as the contents of an iframe, then I ought to be able to use an SVG file that way, too— and JS should run in both or neither, with the same sandbox properties. Probably both.
Is parsing and rendering SVG well-pipelined at this point? Offhand it might be cache-friendly. I have not tried a simple elapsed-time-in-loop test, but to me geometric screen-painting happens instantly enough.
I can imagine a separate branch in computer evolution, if PCs had not happened, where graphical terminals would have evolved to render something SVG-like, support a mouse, and send back simple mousedown/mouseup/x/y data.
They would draw a triangle and then hash the result to get a detailed bowser fingerprint of the victims machine.