GIF vs JPEG
Both these image formats were designed to reduce the size of image files, because images take the most time to download. GIF was the first format that reduces size by eliminating non-web safe colors, resulting in a significant drop in file size. However, photographs in GIF look dulled out. To address this, JPEG was developed. JPEG achieves file size reduction by using mathematical formulae. This results in smaller file size, but images saves in JPEG lose some quality and sharpness.
Today we use GIF to save images with a limited number of colors, and we use JPEG to save hpotographs so that we can preserve all the shades of color in the photograph.