There's manim [1] from YouTuber 3blue1brown. And while it doesn't work on the web, there is a port [2] that does, which runs on p5.js. If you want a bit more control, you can use a canvas animation library directly. A few popular ones are p5, GreenSock, and PixiJS--but there are so many others. For simpler animations and for the most control over the result, it's pretty rewarding to just use the built-in Canvas API [3] directly.
[1] https://github.com/3b1b/manim
[2] https://github.com/JazonJiao/Manim.js/
[3] https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/...