.jpg usually is the smallest file size. .gif is used for animation or if you want transparency, but the file size will be a little bigger. Heres a gif that combines animation and transparency:
Then at some sites they let you use flash, which is a .swf file. Flash is the best program for web animation and .swf's are usually smaller then a .gif would be. There is also .png, which is better than the gif for transparency and quality, plus it is usually smaller.