Jan
21

Image Optimization for the Web: How to Make Images Smaller Without Making Them Look Worse

Learn how to optimize images for faster websites using compression, resizing, WebP, AVIF, responsive images, lazy loading and practical image SEO techniques.

A beautiful website can still feel frustrating if every page takes several seconds to load.

Very often, images are part of the problem.

A photograph exported straight from a camera may be several megabytes. A designer may upload a 3000-pixel-wide banner even though the website displays it at 900 pixels. A PNG might be used for a photograph simply because nobody thought about the format.

None of these choices necessarily make the website look better. They simply make visitors download more data.

Good image optimization is not about aggressively reducing quality until every file is tiny. It is about finding the smallest practical file that still looks good at the size where people will actually see it.

That distinction matters for both user experience and SEO.

Google recommends providing a strong overall page experience and specifically encourages good Core Web Vitals. The current “good” thresholds are an LCP of 2.5 seconds or less, INP below 200 milliseconds, and CLS of 0.1 or less. Images can influence both loading performance and visual stability, especially when the main image is the Largest Contentful Paint element. 

Start With Dimensions Before Compression

One of the most common optimization mistakes is trying to compress an image that is simply too large.

Imagine your blog displays a photograph at a maximum width of 800 pixels. Uploading a 5000-pixel-wide version forces the visitor to download pixels that may never be displayed.

CSS can make that giant image look 800 pixels wide, but CSS does not magically remove the unnecessary image data.

The better approach is to resize the source to dimensions that make sense for its real use.

For responsive websites, one image size may not be enough. HTML's srcset and sizes attributes allow the browser to select an appropriately sized version for the visitor's device instead of forcing every phone, laptop and high-resolution monitor to download exactly the same asset.

web.dev recommends serving images at appropriate dimensions and using responsive images where different screen sizes require different resources. 

A good workflow is therefore:

resize first, then compress.

Compression works much more effectively when it is not being asked to rescue an unnecessarily enormous source file.

Lossy vs Lossless Compression

Image compression normally falls into two broad categories.

Lossless compression reduces file size while preserving all image information needed to reconstruct the original image exactly. It is useful when sharp edges, text, diagrams or transparency are important.

Lossy compression removes some information to achieve substantially smaller files. It works particularly well for photographs, where small reductions in detail can be almost impossible to notice at normal viewing size.

The word “lossy” can sound alarming, but lossy compression is not automatically bad.

A high-quality JPEG or WebP photograph can look virtually identical to the original while occupying far less space. The real mistake is using overly aggressive settings that create obvious blockiness, smearing or banding.

Always inspect the result at its real display size instead of deciding purely from the compression percentage.

JPEG, PNG, WebP or AVIF?

There is no single best format for every image.

JPEG remains useful for ordinary photographs and has extremely broad compatibility. PNG is appropriate when you need lossless reproduction, sharp graphics or transparency.

Modern formats give you more options.

MDN describes WebP as an excellent format for still and animated images, supporting both lossy and lossless compression, transparency and animation. AVIF can achieve even stronger compression in many situations while also supporting transparency and high dynamic range. 

For a practical website:

Photographs: JPEG, WebP or AVIF are usually sensible.

Screenshots and graphics with text: PNG or a lossless WebP/AVIF variant may preserve sharp edges better.

Icons and simple scalable illustrations: SVG is often preferable because it is vector-based and remains sharp at different sizes.

Transparent images: PNG, WebP and AVIF can all support transparency; JPEG cannot.

Modern formats do not mean you must abandon older formats entirely. The HTML <picture> element can provide AVIF or WebP alongside a JPEG or PNG fallback, allowing the browser to choose a supported format. 

Compression Alone Is Not Image SEO

People sometimes treat “image SEO” as a synonym for making images smaller.

It is much broader than that.

Google recommends using standard HTML image elements, descriptive filenames, useful alt text, relevant surrounding content and high-quality images. Google can use alt text along with page content and image analysis to understand what an image represents. 

Consider these filenames:

IMG_983722.jpg

and:

website-speed-dashboard.jpg

The second gives both humans and search engines more context.

Alt text should be equally natural.

Bad:

image website SEO image optimization best image compression webp image

Better:

PageSpeed performance report showing a large hero image as the LCP element

Alt text primarily exists to describe meaningful images to people who cannot see them. Stuffing keywords into it makes the page less useful and can become counterproductive.

Decorative images generally do not need verbose descriptions.

Don't Lazy-Load Everything

Lazy loading is useful because it delays downloading off-screen images until the visitor approaches them.

For an image far down a long article, that is usually a good trade.

For the main image at the top of the page, it may be exactly the wrong choice.

web.dev specifically recommends avoiding lazy loading for images visible in the initial viewport, particularly an image that is likely to become the page's LCP element. Delaying that resource can actually make the perceived page load slower. 

A sensible rule is simple:

Use lazy loading for content that begins off screen. Let important above-the-fold imagery load normally.

Width and Height Matter Too

Have you ever opened a page and started reading, only for the text to suddenly jump downward when an image appeared?

That is layout shift.

When the browser knows an image's dimensions in advance, it can reserve the correct space before downloading the file. Specifying width and height, or otherwise establishing an appropriate aspect ratio, helps prevent unnecessary movement. 

That improves usability and can help CLS, one of the Core Web Vitals.

Optimization therefore includes more than bytes. A well-optimized image also occupies predictable space.

The “Smallest File” Isn't Always the Best Image

A 20 KB hero image may sound impressive until you notice that faces look waxy and gradients have become ugly bands.

Users care about visual quality too.

Google's image guidance explicitly recommends balancing speed with high-quality imagery because sharp and appealing images provide a better user experience and can also make search-result imagery more attractive. 

The target is not:

make every image as small as technically possible.

The better target is:

remove bytes that visitors cannot meaningfully see.

That might mean aggressive compression for a small thumbnail and much gentler compression for a portfolio photograph.

A Practical Image Optimization Workflow

Before publishing an important image, ask five questions.

Is this image larger in dimensions than the website will ever display it?

Is its format appropriate for the kind of visual content it contains?

Can it be compressed further without a noticeable visual penalty?

Does the page reserve its dimensions before it loads?

Does the filename and alt text accurately describe what it shows?

If those answers look good, you have already avoided many of the most common image-performance problems.

Then measure instead of guessing.

PageSpeed Insights and Lighthouse can help identify oversized images, Core Web Vitals problems and other performance bottlenecks. Google recommends measuring page experience rather than assuming that a particular optimization automatically produces a ranking benefit. 

Final Thought

Image optimization is one of those rare technical improvements where everyone can win.

Visitors download less data. Pages feel faster. Mobile users have a better experience. Search engines receive clearer information about your visual content. And you can achieve all of that without turning good photographs into blurry thumbnails.

Start with the correct dimensions. Choose an appropriate format. Compress intelligently. Use responsive images when they add value. Describe meaningful images properly. Then test the real page.

The best optimized image is not necessarily the smallest one.

It is the one that delivers the visual quality your visitor needs with no unnecessary weight.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us