There's no need to use an awful format like gif, just embed an efficiently compressed video file with the <video> tag
Animated gifs do work when embedded, but need to be <= 10mb [2]
[1] https://stackoverflow.com/questions/4279611/how-to-embed-a-v...
[2] https://stackoverflow.com/a/46701929