Guide
The Beginner's Guide to Image Optimization
Everything you need to know about formats, compression, dimensions, SEO, and common mistakes — in plain language.
What is image optimization?
Image optimization means making image files as small as possible without the images looking noticeably worse. The goal is to reduce the amount of data a browser has to download to display your page, which makes the page load faster.
It sounds technical, but the core idea is simple: most images straight from a camera or design tool are far larger than a website actually needs. Optimization closes that gap.
Why it matters
Images typically make up more than half of a web page's total file size. A page full of unoptimized images can take 5–10 seconds to load on a mobile connection. An optimized version of the same page might load in under a second.
Faster pages rank better in Google. Google's Core Web Vitals — a set of performance metrics that directly affect search rankings — include Largest Contentful Paint (LCP), which measures how fast the main image on a page loads. Slow images hurt your LCP score, which hurts your ranking.
Beyond SEO, faster pages have lower bounce rates and better conversion rates. Users on slow connections — especially mobile users — abandon pages that take too long to load.
Understanding image formats
Choosing the right file format is the first and most important optimization decision. Here are the four formats you will encounter most often:
WebP
The best choice for most website images today. WebP supports lossy and lossless compression, transparency, and animation. It produces smaller files than PNG or JPG at equivalent quality and is supported by all modern browsers. When in doubt, use WebP.
JPG (JPEG)
The standard for photographs for decades. JPG uses lossy compression, which means some image data is discarded to reduce file size. It does not support transparency. Still widely used and universally compatible, but WebP is usually a better choice for new work.
PNG
Uses lossless compression — no data is discarded. PNG supports full transparency and is ideal for logos, icons, screenshots, and images with sharp edges or text. Files are larger than WebP or JPG. Best used for source files and images that need to be edited further.
GIF
An old format mainly known for short animations. GIFs are very large files for what they deliver. For animated content, animated WebP or a short video file (MP4) is almost always a better choice.
Lossy vs lossless compression
Lossy compression permanently removes some image data to make the file smaller. The removed data is chosen carefully so the image still looks good at normal viewing sizes. JPG and lossy WebP use lossy compression. You control how much data is removed via a quality setting — typically a number from 0 to 100. A quality setting of 75–85 is a good balance for most web images.
Lossless compression reduces file size without removing any image data. The original image can be perfectly reconstructed from the compressed file. PNG and lossless WebP use lossless compression. Files are larger than lossy equivalents, but quality is guaranteed. Use lossless compression for images you intend to edit.
Getting dimensions right
Uploading a 5000px wide photo to appear at 800px wide wastes a huge amount of bandwidth. The browser downloads all 5000px worth of data and then scales it down to display it at 800px. Only the 800px version of the data was ever needed.
Before uploading, resize each image to approximately the size it will be displayed. For a blog post image, 1200–1600px wide is usually plenty. For a small thumbnail, 400–600px is enough. For a full-width hero image on a desktop, 1600–2000px handles even retina displays well.
Image optimization and SEO
Image optimization improves SEO in several ways:
- Page speed: Faster pages rank better. Google uses page speed as a ranking signal, and images are typically the biggest contributor to slow load times.
- Alt text: The
altattribute tells search engines what an image shows. Write clear, descriptive alt text for every image. This also makes your site accessible to visually impaired users. - File names: Use descriptive file names before uploading.
webp-vs-png-comparison.webpis more useful to search engines thanIMG_4821.jpg. - Core Web Vitals: LCP (Largest Contentful Paint) is heavily influenced by how fast your main image loads. Optimized images directly improve your LCP score.
Common mistakes to avoid
- Uploading full camera resolution. A 12-megapixel camera produces images around 4000×3000px. No website element is that large. Always resize before uploading.
- Using PNG for all images. PNG is lossless and large. Photos and complex images are almost always smaller as WebP or JPG with no visible quality difference.
- Skipping alt text. Empty or missing alt attributes hurt SEO and accessibility. Every image deserves a description.
- Ignoring below-the-fold images. Add
loading="lazy"to images that are not visible on initial page load. - Never checking actual file sizes. Open your browser's developer tools, go to the Network tab, and see exactly how large your images are when they load. Many people are surprised.
A simple optimization workflow
Here is a repeatable process for every image you add to a website:
- Resize the image to the largest size it will be displayed
- Convert to WebP format
- Set quality to 80–85% for photos; use lossless for logos and graphics
- Check the output file size — it should be well under 200KB for most images
- Write a descriptive file name before saving
- Add descriptive alt text when you add it to your page
- Add
loading="lazy"if the image is below the fold
Following this workflow consistently makes a noticeable difference in page load speed over time.
More image guides
Keep reading to go deeper on specific topics.
WebP vs PNG: Which Image Format Should You Use?
A practical guide to file size, transparency, and when to use each format.
Read guide → PerformanceHow to Speed Up Website Images Without Losing Quality
Simple ways to make website images smaller and faster without ruining quality.
Read guide →