Web & Development

How to Optimize Website Images for SEO and Speed: The Complete Guide

How to Optimize Website Images for SEO and Speed: The Complete Guide

Learn how to optimize website images for faster loading and better Google rankings. Choose the right formats, compress images, improve Lighthouse scores, write effective alt text, and fix common image SEO problems.

Images make websites more attractive, explain complex ideas, and help visitors discover products. But poorly optimized images can also slow down a website, waste bandwidth, and make pages harder for search engines to understand.

A photograph uploaded directly from a smartphone may weigh several megabytes, even when it appears at just 600 pixels wide on a webpage. Multiply that by ten images, and visitors could be downloading far more data than necessary.

Fortunately, optimizing images does not require expensive software or advanced programming skills.

In this guide, you will learn how to choose suitable image formats, resize and compress files, improve Lighthouse performance, write effective alternative text, and help Google discover your images.

We will also cover practical workflows for WordPress, Joomla, and custom websites.

1. Why image optimization matters

Image optimization has three complementary goals.

Performance: Reduce unnecessary downloads so pages load faster, especially on mobile connections.

Search visibility: Help Google understand and discover the images published on your website.

Accessibility: Ensure that people using assistive technologies can understand meaningful visual content.

These goals are related, but they are not interchangeable.

Converting a photograph to WebP may improve its download size, but it does not automatically improve its alternative text.

Similarly, adding descriptive alt text will not fix an image that is unnecessarily large.

A well-optimized image combines appropriate dimensions, efficient encoding, relevant content, and correct HTML integration.

Google's image SEO documentation explicitly recommends both efficient image delivery and meaningful descriptions.

2. Choose the right image format

There is no single format that is best for every image.

The right choice depends on what the image contains, whether transparency is required, and how the image will be displayed.

Format Typical use Main consideration
JPEG Photographs, legacy compatibility Widely supported, but often larger than modern alternatives
PNG Screenshots, graphics requiring lossless detail Can be unnecessarily large for photographs
WebP Photographs, article illustrations, product images Excellent practical default for many websites
AVIF Photographs and images where maximum compression is valuable Test visual quality and encoding behavior
SVG Logos, icons, simple vector illustrations Requires safe handling of untrusted files
GIF Simple legacy animations Animated WebP or video may be more efficient

Why WebP is often a good default

WebP supports both lossy and lossless compression, as well as transparency.

For ordinary photographs and article illustrations, it frequently produces smaller files than JPEG at comparable perceived quality.

That makes it a convenient default for websites where images need to load quickly across many devices.

However, WebP is not automatically the smallest possible format. AVIF may achieve better compression for some images, while PNG can remain appropriate for screenshots with fine text or graphics that require exact pixel reproduction.

For a detailed comparison of the technologies, see our existing article: WebP, AVIF and JPEG XL comparison.

For this guide, the practical rule is simple: start with WebP for typical website photographs, compare alternatives when useful, and always inspect the actual result.

What about Lighthouse?

Lighthouse does not award points simply because a file has a .webp extension.

Its image-delivery diagnostics focus on opportunities to reduce unnecessary transferred bytes, including inefficient encoding and oversized image resources.

A properly resized JPEG can sometimes outperform a poorly compressed WebP.

The objective is efficient delivery, not adopting a particular extension at any cost.

3. Resize images before uploading them

One of the most common mistakes is uploading images at their original camera resolution.

Imagine a photograph measuring 4,000 × 3,000 pixels.

On your website, it appears inside an article column that is only 800 CSS pixels wide.

The original contains far more pixels than the layout needs.

Understand displayed size and file dimensions

An image's displayed width is not necessarily the same as the resolution of the downloaded file.

For example:

  • Displayed width: 800 CSS pixels.
  • Standard-density screen: approximately 800 physical pixels across that area.
  • Double-density screen: approximately 1,600 physical pixels may be useful for sharper rendering.

This does not mean every image must be exported at twice its displayed width. It means the ideal resolution depends on layout, device pixel density, image content, and bandwidth.

Practical starting dimensions

Image use Suggested starting width
Small card thumbnail 400–800 px
Standard article image 1000–1400 px
Wide article hero 1600–2000 px
Product detail image 1200–2000 px
Small icon Use SVG when appropriate

These are starting points, not universal requirements. A responsive website should ideally provide multiple sizes instead of forcing every device to download the largest file.

Example

Suppose your original photograph is 4000 × 3000 pixels and weighs 3.2 MB.

You resize it to 1200 × 900 pixels and export it as WebP.

The result might be around 100–250 KB, depending on photographic detail and compression settings.

That range is illustrative, not a guaranteed result.

The important point is that resizing and compression work together.

4. Compress images without making them blurry

Compression reduces the amount of data required to store an image.

There are two main approaches.

Lossless compression preserves the image data exactly when decoded.

Lossy compression removes some information to achieve smaller files.

For most photographs displayed on websites, moderate lossy compression is appropriate because small differences may be visually imperceptible.

However, aggressive compression can create visible problems:

  • Blurred textures.
  • Blocky edges.
  • Color banding.
  • Distorted text.
  • Loss of fine product details.

The correct compression level depends on the image.

A landscape photograph may tolerate stronger compression than a product photograph containing small labels.

A practical workflow using Squoosh

Free browser-based image optimization tool

Squoosh provides an accessible way to resize images, compare formats, and inspect compression quality.

Follow these steps:

  1. Open Squoosh and import a photograph.
  2. Enable resizing if the original dimensions are excessive.
  3. Enter the desired width, such as 1200 pixels, preserving the aspect ratio.
  4. Select WebP as the output format.
  5. Start with a quality setting around 75–85 as an experiment.
  6. Compare the original and compressed versions at 100% zoom.
  7. Check fine details, text, faces, and high-contrast edges.
  8. Adjust the quality until the result looks acceptable.
  9. Download the optimized file.

The quality setting is an encoder parameter, not a universal percentage of visual fidelity.

A setting of 80 in one format or tool is not necessarily equivalent to 80 in another.

What file size should you target?

There is no universal maximum.

A small thumbnail should generally require less data than a full-width hero photograph.

A useful approach is to aim for the smallest file that still looks good at its intended display size.

As practical initial targets, you might investigate:

  • Thumbnails exceeding 100 KB.
  • Standard article photographs exceeding 200–300 KB.
  • Hero images exceeding 300–500 KB.

These are diagnostic guidelines, not Lighthouse thresholds or Google ranking requirements.

A detailed image may legitimately need more data.

5. A complete before-and-after example

Consider a gardening blog publishing an article about growing tomatoes.

The editor has a photograph of tomato seedlings.

Original Optimized
File size 2.8 MB 160 KB
Format JPEG WebP
Dimensions 4000 × 3000 px 1200 × 900 px

94.3% smaller — Illustrative scenario. The figures demonstrate a possible result, not a measured conversion. Actual savings depend on image content and export settings.

The optimization process is:

  1. Resize the image to a suitable width.
  2. Export it using WebP compression.
  3. Verify that important details remain visible.
  4. Give the file a descriptive name.
  5. Upload it to the website.
  6. Add relevant alternative text.
  7. Verify how the browser loads it.

A possible filename is:

tomato-seedlings-container.webp

A suitable alternative text is:

Young tomato seedlings growing in a container filled with potting soil

This single workflow addresses both technical performance and search visibility.

6. Use responsive images to avoid unnecessary downloads

A website may display the same photograph on a large desktop monitor and a narrow smartphone.

If every visitor downloads a 2000-pixel-wide image, mobile users may receive much more data than needed.

Responsive images solve this problem by offering several versions of the same image.

For example:

<img
  src="tomato-seedlings-1200.webp"
  srcset="
    tomato-seedlings-480.webp 480w,
    tomato-seedlings-800.webp 800w,
    tomato-seedlings-1200.webp 1200w
  "
  sizes="(max-width: 768px) 100vw, 800px"
  width="1200"
  height="900"
  alt="Young tomato seedlings growing in a container"
>

Here:

  • src provides a fallback image URL.
  • srcset lists available image widths.
  • sizes tells the browser how much layout space the image is expected to occupy.
  • width and height communicate the image's aspect ratio.
  • alt describes its meaningful content.

The browser selects an appropriate resource based on the available candidates, layout information, and device characteristics.

Do WordPress and Joomla users need to write this code?

Usually not.

WordPress generates multiple image sizes and can produce responsive image attributes automatically for supported images.

Joomla behavior depends on its version, editor, template, and installed image-processing extensions.

The important task for site owners is to check the result, not necessarily to implement srcset manually.

If a mobile page still downloads a huge image, inspect the generated HTML and the theme's image settings.

7. Prevent layout shifts with image dimensions

Have you ever opened a page and watched the text suddenly jump downward when a photograph appeared?

That is a layout shift.

It happens when the browser has not reserved enough space for content that loads later.

Images without predictable dimensions are a common cause.

Illustration of the article's main concept

A simple improvement is to specify intrinsic dimensions:

<img
  src="tomato-seedlings.webp"
  width="1200"
  height="900"
  alt="Tomato seedlings in a planting container"
>

With responsive CSS:

.article-content img {
  max-width: 100%;
  height: auto;
}

The browser can use the width and height attributes to calculate the aspect ratio before the image finishes loading.

This helps reduce unexpected layout movement.

What about cropped images?

If a design intentionally crops images to a fixed shape, the CSS must also reserve that shape.

For example:

.article-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

This can work well for article cards.

However, avoid using aggressive cropping for product images where important details must remain visible.

8. Use lazy loading carefully

Lazy loading delays downloading images until they are near the visible area.

This can reduce initial page weight when an article contains many images.

For images located far below the first screen, it is often helpful:

<img
  src="garden-tools.webp"
  loading="lazy"
  width="1200"
  height="800"
  alt="Gardening tools arranged on a wooden table"
>

But lazy loading is not appropriate for every image.

Do not automatically lazy-load the main hero image

The largest visible image near the top of a page may be its Largest Contentful Paint (LCP) element.

LCP is one of Google's Core Web Vitals.

If the browser delays downloading that image, the main content may appear later than necessary.

For a hero image that is known to be important, you can consider:

<img
  src="tomato-garden-hero.webp"
  width="1600"
  height="900"
  loading="eager"
  fetchpriority="high"
  alt="Ripe tomatoes growing on plants in a garden"
>

fetchpriority="high" is a browser scheduling hint. It should be reserved for genuinely important resources rather than added to every image.

Do not combine loading="lazy" with high priority for an image you want loaded immediately.

When should you use lazy loading?

Image location Typical approach
Main visible hero Eager loading; consider high priority
Image visible immediately Usually avoid lazy loading
Image halfway down an article Lazy loading is often useful
Footer illustration Lazy loading is usually appropriate
Product gallery Prioritize the first visible image; defer others where appropriate

The correct strategy depends on the actual layout and which element becomes LCP.

9. Improve image SEO with descriptive filenames

Now that the image is technically optimized, help search engines understand it.

Start with the filename.

A camera-generated name such as:

IMG_5843.webp

provides very little information.

A descriptive name such as:

handmade-blue-ceramic-mug.webp

offers useful context.

Google states that filenames can provide light clues about image content. They are helpful, but not a substitute for relevant page content.

Examples

Poor filename Better filename
photo1.webp wooden-garden-bench.webp
image-final.webp solar-garden-light.webp
product-123.webp blue-ceramic-coffee-mug.webp
screen01.png wordpress-alt-text-settings.png

Use meaningful words, avoid keyword repetition, and keep filenames reasonably short.

Should you rename existing images?

Be careful.

Changing a filename usually changes the image URL.

If that URL is already indexed, linked from other pages, or used by your CMS, renaming it may create broken references.

For existing images, prioritize fixing serious problems rather than renaming everything.

If a URL must change, update references and use an appropriate permanent redirect where possible.

10. Write alternative text for accessibility and SEO

Alternative text describes meaningful image content for people who cannot see it.

It also helps search engines interpret the image.

For example, consider a photograph of a blue ceramic mug.

Too vague:

alt="Mug"

Keyword stuffing:

alt="Blue mug ceramic mug coffee mug best mug buy blue mug"

Better:

alt="Handmade blue ceramic coffee mug with a curved handle"

The last version is descriptive without being repetitive.

Context matters

The same image can have different appropriate alt text depending on its purpose.

On a product page:

Handmade blue ceramic coffee mug with a curved handle

In an article about glazing:

Glossy blue glaze on the surface of a handmade ceramic mug

Both can be useful because they emphasize different information.

Decorative images are different

If an image is purely decorative and communicates no information, use an empty alt attribute:

<img src="decorative-divider.svg" alt="">

This helps screen readers skip unnecessary content.

Do not add keyword-filled descriptions to decorative elements.

The W3C Images Tutorial provides detailed guidance for informative, decorative, functional, and complex images.

11. Add image SEO information in WordPress and Joomla

Most site owners can handle image optimization without editing HTML.

WordPress

A practical workflow is:

  1. Resize and compress the image before uploading it, or use a trusted image optimization solution.
  2. Open the WordPress Media Library.
  3. Upload the optimized file.
  4. Enter meaningful alternative text.
  5. Insert the image into the appropriate article section.
  6. Verify the image's actual appearance and dimensions.
  7. Check that the generated page uses the intended image size.

WordPress can generate intermediate image sizes automatically, but that does not mean every uploaded image is already optimally compressed.

For websites with large media libraries, image optimization plugins can automate parts of the process.

Examples include ShortPixel and Imagify.

Before installing a plugin, check what it does to original files, whether it generates WebP or AVIF, whether it changes image URLs, and how it handles backups.

Avoid stacking several image optimization plugins that perform overlapping transformations.

Joomla

Joomla users can follow the same general workflow:

  1. Prepare the image with Squoosh or another image editor.
  2. Upload it through Joomla's Media Manager or the editor's image interface.
  3. Insert it into the relevant article.
  4. Set meaningful alternative text.
  5. Check the dimensions and rendering in the template.
  6. Verify the actual image URL and file size in the browser.

Some Joomla templates and extensions provide responsive images, WebP generation, or lazy loading.

Others may require manual preparation or additional configuration.

The important distinction is that uploading a WebP file is not the same as verifying that the browser receives an appropriately sized WebP file.

12. Make images discoverable by Google

An optimized image is not guaranteed to appear in Google Images.

Google must be able to discover it, crawl it, and understand the page where it appears.

Use standard HTML images

For important content images, use an HTML <img> element.

<img
  src="/images/solar-garden-light.webp"
  alt="Solar garden light illuminating a stone pathway"
>

Google documents that it discovers images through standard HTML image elements, including those inside <picture> elements.

It does not index CSS background images as images in the same way.

CSS backgrounds remain useful for decoration, but they should not be your only method of displaying important editorial or product imagery.

Place images near relevant text

A photograph of tomato seedlings should appear near the section about planting seedlings.

The surrounding heading, paragraph, and caption help explain why the image matters.

Use captions when useful

Alternative text and captions serve different purposes.

Alt text describes the image's meaningful visual content.

A caption adds visible context for readers.

For example:

Alt text: Drip irrigation tubing installed around tomato plants

Caption: Drip irrigation delivers water close to plant roots and can help limit unnecessary watering.

Not every image needs a caption. Add one when it helps explain the content.

Keep image URLs accessible

Technical workflow illustration

Check that:

  • The image URL loads successfully.
  • The file is not restricted to authenticated users.
  • Crawling is not blocked unnecessarily.
  • The containing page is indexable.
  • Important images are present in the rendered HTML.

Image sitemaps can help discovery, particularly for large image collections or images that are otherwise difficult for crawlers to find.

They are not a mandatory requirement for every small website.

13. Choose the right featured image and social preview

The featured image represents your article in several contexts.

It may appear in article listings, social sharing previews, and sometimes search-related surfaces.

Choose an image that genuinely represents the page.

For an article about solar garden lights, use a relevant photograph of a solar garden light rather than an unrelated generic technology image.

Your CMS or SEO extension may let you configure Open Graph metadata:

<meta
  property="og:image"
  content="https://example.com/images/solar-garden-light.webp"
>

Google also supports relevant structured data properties for expressing preferred images.

However, Google ultimately controls which preview it displays. Setting og:image is not a guarantee.

For product pages, use genuine product photography and avoid misleading alterations that change the product's appearance.

14. Check image performance with PageSpeed Insights

You have optimized your files. Now verify whether the website actually benefits.

Open PageSpeed Insights.

Enter the URL of an article or product page and run the analysis.

Start with the mobile results.

Understand the most relevant metrics

Largest Contentful Paint (LCP) measures when the largest visible content element finishes rendering. A large hero image can affect it.

Cumulative Layout Shift (CLS) measures unexpected visual movement. Images without reserved dimensions can contribute to layout shifts.

Speed Index and other Lighthouse metrics provide additional diagnostic context.

PageSpeed Insights may show real-user field data when enough data is available, alongside a simulated Lighthouse test.

These are different sources of information and should not be interpreted as identical measurements.

What to investigate in image-related diagnostics

Finding Likely cause What to try
Improve image delivery Oversized or inefficiently encoded image Resize, recompress, or use a more efficient format
Image-related LCP delay Main image discovered or loaded late Avoid unnecessary lazy loading; review priority
Layout shifts Missing image dimensions Add dimensions or reserve aspect ratio
Excessive network payload Too many or overly large images Reduce bytes and defer offscreen resources
Poor mobile image performance Desktop-sized files delivered to mobile Use responsive image variants

Do not optimize exclusively for a Lighthouse score.

A page with a perfect laboratory score but blurry product photographs is not a good outcome.

Aim for a balanced result: useful image quality, efficient loading, and a good real-world user experience.

15. Monitor image search traffic in Google Search Console

Performance optimization and search visibility should be evaluated separately.

For search visibility, open Google Search Console.

In the Search performance report:

  1. Select your website property.
  2. Open the search type filter.
  3. Choose Image.
  4. Review impressions, clicks, queries, and landing pages.
  5. Compare performance over a meaningful period.

Suppose a gardening article receives many impressions in Google Images but few clicks.

Review whether its images accurately match the search queries, whether the page is relevant, and whether the photographs are useful and appealing.

Do not assume low click-through rates are caused by missing alt text.

Search Console can help identify opportunities, but it does not provide a complete per-image diagnosis for every embedded file.

For crawling and indexing issues, also inspect the page URL and verify that image resources are accessible.

16. Common image optimization mistakes

Mistake 1: Converting everything to WebP without resizing

A 4000-pixel WebP may still be unnecessarily large for a 500-pixel display area.

Fix: Resize first, then compress.

Mistake 2: Compressing images too aggressively

Small file size is not useful if product details become blurry.

Fix: Compare the output visually and preserve important information.

Mistake 3: Lazy-loading the hero image

The main image may be delayed, hurting LCP.

Fix: Identify the actual LCP element and prioritize it appropriately.

Mistake 4: Uploading one large image for every screen size

Mobile users may download unnecessary pixels.

Fix: Use responsive image variants where supported.

Mistake 5: Forgetting image dimensions

Images may cause layout shifts while loading.

Fix: Provide dimensions or reserve the correct aspect ratio.

Mistake 6: Adding keywords instead of useful alt text

Keyword stuffing reduces clarity and accessibility.

Fix: Describe the image naturally in context.

Mistake 7: Optimizing files but ignoring the page

Even a small image can be poorly integrated.

Fix: Check the HTML, loading behavior, surrounding text, and actual browser requests.

Mistake 8: Renaming all existing images

Mass changes can break indexed URLs and internal links.

Fix: Prioritize meaningful improvements and preserve established URLs where possible.

Mistake 9: Using several image optimization plugins simultaneously

Overlapping plugins can generate duplicate files, conflicting rewrites, or unexpected results.

Fix: Use one coherent image-processing workflow and test it before applying bulk changes.

Mistake 10: Assuming every image must be WebP

Some screenshots, vector graphics, and specialized assets benefit from other formats.

Fix: Choose based on content, visual quality, compatibility, and measured file size.

17. Special cases: ecommerce, screenshots, logos, and image galleries

Different image types require different optimization strategies.

Ecommerce product images

Product photography should prioritize accuracy.

A smaller file is not an improvement if compression removes details customers need to evaluate the product.

For a product page:

  • Preserve accurate colors and textures.
  • Provide enough resolution for useful zooming.
  • Use smaller thumbnails in product listings.
  • Load the primary product image promptly.
  • Defer secondary gallery images where appropriate.
  • Describe visible product characteristics accurately.
  • Use relevant product structured data when supported by your ecommerce platform.

If the product has a label, engraving, or important technical detail, inspect that area after compression.

Screenshots and tutorials

Screenshots often contain small text, icons, and interface details.

Aggressive lossy compression can make these elements difficult to read.

Try PNG, lossless WebP, or carefully configured lossy compression, and compare the results.

Crop unnecessary browser chrome or empty margins when doing so does not remove important context.

A screenshot should remain readable at the size displayed in the article.

Logos and icons

SVG is often suitable for logos and simple vector illustrations because it scales without losing sharpness.

For a logo used throughout a website, an SVG can be more appropriate than exporting several large raster files.

Only use SVG files from trusted sources or sanitize uploaded SVG content. SVG can contain active content and should not be treated as inherently harmless.

Image galleries

A gallery with 30 photographs can generate substantial network traffic.

Use appropriately sized thumbnails, lazy-load offscreen images, and avoid loading full-resolution originals before visitors request them.

For galleries with zoom or lightbox functionality, the thumbnail and expanded image can be separate resources.

Background images

Decorative backgrounds can be implemented with CSS, but they still need appropriate dimensions and compression.

For large visual backgrounds, consider separate assets for desktop and mobile layouts.

If a background image contains meaningful information that visitors need, provide an accessible equivalent rather than relying exclusively on CSS.

18. A practical workflow you can repeat for every image

Here is a complete procedure for publishing a photograph in an article.

Image optimization checklist

  • [ ] Choose an image that genuinely supports the article.
  • [ ] Verify that you have the right to use it.
  • [ ] Crop unnecessary areas and choose the intended aspect ratio.
  • [ ] Resize to suitable dimensions.
  • [ ] Compare WebP, AVIF, JPEG or PNG when appropriate.
  • [ ] Compress while preserving visible details.
  • [ ] Use a descriptive filename.
  • [ ] Upload the image to your CMS.
  • [ ] Add meaningful alt text or an empty alt for decoration.
  • [ ] Add a caption if it improves understanding.
  • [ ] Verify mobile display and image dimensions.
  • [ ] Check lazy loading and the main image's priority.
  • [ ] Run PageSpeed Insights on the published page.
  • [ ] Confirm the image URL and page are crawlable.

For most website owners, the greatest improvements will come from following this process consistently, rather than repeatedly experimenting with increasingly complex optimization settings.

Conclusion: Optimize the image, then verify the result

Effective image optimization is not just about converting JPEG files to WebP.

It means selecting the right image, preparing it at appropriate dimensions, using efficient compression, loading it intelligently, and providing the information that people and search engines need to understand it.

Start with the images that matter most: your homepage hero, important article illustrations, and product photographs.

Then check the actual results with PageSpeed Insights and monitor search visibility with Google Search Console.

The objective is not the smallest possible image or a perfect Lighthouse score. It is a website that remains visually useful, loads efficiently, and gives every important image the best opportunity to be discovered.

For a deeper explanation of modern image formats, continue with our WebP, AVIF and JPEG XL comparison.