Image Optimization
History & evolution
Image compression was born in the 1980s with the first scanners and digital cameras. The JPEG format (1992) revolutionized digital storage with DCT (Discrete Cosine Transform) compression, reducing files by up to 90% without visible loss. Before JPEG, digital photographs occupied megabytes and were impractical to share.
Evolution continued with PNG (1996) for graphics with transparency, animated GIF (1987-1989), WebP (2010) with better compression, and recently AVIF (2020) with AI codecs.
Google's Core Web Vitals (LCP, FID, CLS) penalize unoptimized images. A 2MB image can take 8-10 seconds to load on 3G, while an optimized 200KB version loads in less than 1 second.
Best practices
To maximize web performance and user experience, follow these professional recommendations:
Choose the right format for each image type. Use JPEG for photographs (better lossy compression), PNG for logos and icons with transparency, WebP for everything with better compression, and GIF only for simple animations.
Adjust quality according to final use. Hero images: 85-90% quality. Content images: 75-80%. Thumbnails: 60-70%.
Resize before compressing. Never display a 4000px image when the container is 800px. Resize to the exact needed size first.
Implement lazy loading and responsive images. Use loading="lazy" and srcset to serve different sizes according to the device.
Use cases
Image optimization is critical in multiple scenarios: e-commerce (products with multiple high-resolution photos), blogs and digital magazines (article photography), creative portfolios (high-resolution galleries), mobile apps (icons and assets), and social networks (avatars, user-generated content).
Companies like Amazon aggressively optimize product images, achieving sub-second loading times. Instagram automatically compresses all uploads to maintain a fluid experience. WordPress incorporates automatic optimization since version 5.8. For online stores, reducing image weight by 60% can increase conversions by 15 to 20%, according to Google PageSpeed studies.
Curiosities
- The JPEG format was created in 1992 by the Joint Photographic Experts Group and uses the Discrete Cosine Transform (DCT), the same mathematics behind MP3 audio compression.
- A single modern smartphone RAW photo can exceed 30 MB. The same image optimized for web in WebP can weigh less than 200 KB. A 99% reduction.
- Google released the WebP format in 2010 with the goal of making the web 30% faster. Lossy WebP images are typically 25-34% smaller than equivalent JPEGs.
- The AVIF format (2020), based on the AV1 video codec, can compress images up to 50% compared to JPEG while maintaining the same perceived visual quality.