GIFS are massive compared to h.264, basically because GIF was developed in the olden days (1987), and h.264 was developed in the… well in the less olden days (2003). Here's a 72kb h.264 file
And here's the same thing converted to a GIF. Total file size 1,212kb, or roughly 16 times the size, and the quality leaves a lot to be desired.
h.264 is a codec that was designed for the purpose of delivering high visual quality with small file sizes. It is almost universally readable by any remotely modern browser, and is free to use for most users. The only thing going for GIFs is that they are classified as an image format, so platforms like stackexchange will allow you to embed them, whereas they don't let you embed video. Go figure.
The only alternatives that I could suggest are webm which is open source but slightly less ubiquitous, and h.265 which works even better, but again is less universally playable.