I've resigning myself to letting diagrams on the web be images. (1) Design the diagram in TikZ, or anything really, (2) screenshot/crop it, (3) make its background transparent with imagemagick, and (2) convert to .webp
If you're going to build something in JS, you'd have to decide how a wide diagram should adjust to render legibly on a narrower viewport (mobile), and that sounds rough.