Scribunto recently added support for Lua to generate SVGs rendered as <img> in T405861. This renders SVGs in secure animated mode which allows declarative animations but not interactions. There are some use cases where interactivity would be helpful to illustrate article content.
This can be done by emitting <svg> elements to html, after passing them through a sanitizer to strip elements and attributes that could trigger external resource loads or script execution (T334953). The interface for this in Scribunto could be a new :toTag() method in mw.svg.
Previously discussed within T334372.
| Feature | Unsanitized, as <img> (Supported) | Sanitized, as <svg> (Proposed) |
| Declarative animations | Yes | Yes |
| Interactivity | No, blocked by browser | Yes |
| Script execution | No, blocked by browser | No, blocked by MediaWiki |
| External references | No, blocked by browser | No, blocked by MediaWiki |