Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To optimize pictures for a website, serve only the pixels the page needs, choose a format and compression level that preserve acceptable visual quality, provide responsive image sources, reserve the image’s layout space, and load it at the right time. Then inspect the actual page and its image downloads: no format or quality setting guarantees a particular performance score.

1. Start with the image’s job and display size

Before exporting or converting a picture, identify where it appears and what it needs to communicate. A large photograph, a small logo, an icon, and a screenshot containing text have different visual requirements. The right optimization is the smallest file that still looks suitable in its actual placement—not simply the smallest file you can produce.

Check the rendered slot

Find the image’s rendered width and height in the layouts where it appears. Avoid downloading a substantially larger image than the display context requires: unnecessarily large dimensions add bytes without improving the image at that size. If the same asset appears in substantially different slots or across viewport sizes, prepare a modest set of appropriately sized variants instead of using one oversized file everywhere.

Account for image type

  • Photographs: often tolerate lossy compression, but inspect fine detail, gradients, and faces at the size people will see them.
  • Text-heavy graphics and sharp-edged artwork: can reveal blur, ringing, or other compression artifacts, so compare exports carefully.
  • Logos and icons: may be better represented by SVG when suitable; SVG is text-based, and minification and compression can apply to its content.
  • Images needing transparency: check that the chosen format and export preserve it.

Keep the original asset. That lets you make a new crop, size, or quality variant without repeatedly recompressing an already degraded export.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Choose a format by testing the actual image

WebP and AVIF can compress images more efficiently than JPEG or PNG, but neither is guaranteed to be smaller at the same perceived quality for every image. WebP supports lossy and lossless modes and transparency. AVIF also supports lossy and lossless compression and may produce smaller files than JPEG in some cases. Decide by comparing the actual output, the image’s requirements, and the browser support your implementation needs. web.dev’s image performance guidance discusses formats and compression trade-offs.

Make a controlled comparison

  1. Choose a representative source image and retain its original dimensions.
  2. Export candidate versions in the formats you are considering, using more than one compression setting where applicable.
  3. Compare resulting file sizes and inspect the candidates at their intended display size. Also zoom in on text, fine lines, and high-contrast edges.
  4. Check transparency, crop, and browser support requirements before selecting an output.
  5. Repeat with other representative images. A result that works for a photograph may not work for a logo or text-heavy graphic.

Lossy compression discards some image information in exchange for smaller files and often suits photographs. Lossless compression preserves image data but may produce larger files. There is no universal quality value that works for every picture; choose based on the visible result and bytes for that asset.

3. Offer responsive image files

Responsive markup lets the browser choose among image candidates rather than forcing a small-screen visitor to download a desktop-sized resource. Use srcset to list alternatives and sizes to describe the image’s expected rendered slot. The browser can use that information to select a suitable resource. Use <picture> when you need explicit format alternatives or different crops (art direction). See web.dev’s responsive images guide for the behavior and markup options.

Example: candidates for one image slot

Replace the example paths with files you have actually generated, and adjust sizes to match your page’s layout. Candidate widths should describe the pixel widths of the corresponding files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<img
  src="/images/field-800.jpg"
  srcset="/images/field-400.jpg 400w,
          /images/field-800.jpg 800w,
          /images/field-1200.jpg 1200w"
  sizes="(max-width: 600px) 100vw, 800px"
  width="1200"
  height="800"
  alt="A field beside a tree-lined path">

Here, sizes says the slot is the viewport width up to 600 CSS pixels and 800 CSS pixels on wider screens. That is only correct if it matches the real layout. If the image occupies half the desktop content area, for example, describe that smaller slot instead. Incorrect slot information can lead the browser to select a candidate that is larger or smaller than intended.

Example: offer WebP with a fallback

Use <picture> when you want to offer an alternate format and retain a fallback image source. Ensure the alternatives show the same intended image and that the fallback is a usable format for the browsers you need to support.

<picture>
  <source type="image/webp"
          srcset="/images/field-400.webp 400w,
                  /images/field-800.webp 800w"
          sizes="(max-width: 600px) 100vw, 800px">
  <img src="/images/field-800.jpg"
       srcset="/images/field-400.jpg 400w,
               /images/field-800.jpg 800w"
       sizes="(max-width: 600px) 100vw, 800px"
       width="1200" height="800"
       alt="A field beside a tree-lined path">
</picture>

Responsive variants improve the browser’s ability to match a resource to a slot, but each extra variant also creates another file to produce and maintain. Generate enough candidates to cover meaningful layout differences; do not create variants without a delivery need.

4. Reserve layout space and choose loading behavior

Image delivery is not just a file-size decision. The browser also needs to know how much space an image occupies and whether it should fetch it immediately. Correct intrinsic dimensions or an otherwise reserved aspect ratio help prevent layout movement as the image loads. web.dev’s images guide covers image attributes and layout behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Lazy-load content below the fold

For images that are below the initial viewport and do not need to appear immediately, use loading="lazy". This can defer work for content a visitor may not reach. Do not apply it to the hero or another image likely to be the page’s largest contentful paint (LCP) image; delaying a critical image can make it appear later.

Keep the critical image available promptly

Leave the likely LCP image eager rather than lazy-loaded. If it is genuinely critical, fetchpriority="high" is an option, but avoid applying high priority indiscriminately: it can divert priority from other resources. A lower-page example might look like this:

<img src="/images/article-detail.webp"
     width="800" height="533"
     loading="eager"
     alt="Close-up detail of the finished project">

For a genuinely critical hero image, omit loading="lazy"; consider high fetch priority only when that image warrants it. Set accurate width and height values for both cases. These loading recommendations are covered in web.dev’s responsive images guide.

5. Measure the page and refine the largest waste

After changing image files or markup, inspect the page’s image payloads and loading behavior with performance tools. Test representative layouts, devices, and network conditions, then check that the rendered pictures still look acceptable. Prioritize images that are unusually large for their displayed size or that account for substantial page downloads. Repeat after meaningful changes to crops, layout, assets, or delivery behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Image optimization can help loading performance, including LCP, but it does not determine a page’s overall Core Web Vitals result. Google describes Core Web Vitals as real-world measures of loading performance, interactivity, and visual stability; switching image formats alone does not guarantee a passing result. See Google Search Central’s Core Web Vitals overview. Image presentation and discoverability also involve more than compression; Google’s Image SEO best practices covers that separate concern.

Tools can help compare exports and inspect pages. The official web.dev image performance guide names Squoosh and ImageOptim and also describes image optimization services as an option. Select a workflow that lets you check output quality and delivery behavior; automation does not remove the need to validate representative images.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Troubleshoot common optimization problems

The page still downloads an oversized image on a phone

Check that the image has real, appropriately sized candidates in srcset and that the sizes value matches the rendered slot at that viewport. Confirm the candidate paths resolve to the intended files and that the smaller candidates are genuinely smaller images, not just differently named copies.

The compressed image looks smeared or has halos

Try a less aggressive lossy setting or a different format, then compare at the actual display size. Inspect text and high-contrast boundaries especially closely. For artwork where preserving exact pixel data is important, compare a lossless export, accepting that it may be larger.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The image appears late even though it is above the fold

Check whether it was given loading="lazy". Remove lazy loading from the hero or other likely LCP image. If it is truly the critical image, consider fetchpriority="high" selectively rather than adding high priority to many resources.

The page jumps as the image loads

Provide accurate intrinsic width and height attributes or reserve the correct aspect ratio through the layout. Verify that the dimensions and crop match the rendered asset; inaccurate values can reserve the wrong space.

A format alternative is missing or looks different

Check the paths and declared source type in <picture>, and verify the fallback <img> works. Compare the candidate images to confirm they use the intended crop, transparency, and quality. Do not assume a format conversion preserved every property of the source.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not an image-compression tool: use it when you need a rendered page capture to review or share after making image changes. One GET request can return a screenshot or PDF. For example, this cURL request captures a page as WebP:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API details. ScreenshotNeo accepts cookie/consent banners as a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan. Sign up for 1,000 free screenshots a month, with no card required.

Frequently asked questions

Does optimizing pictures guarantee better Core Web Vitals?

No. Image changes may improve loading behavior, but Core Web Vitals cover loading, interactivity, and visual stability across the real-world experience. Evaluate the page rather than treating a format change as a guaranteed score improvement.

Should every image have an AVIF or WebP version?

Not automatically. Compare candidate file sizes and visual quality for the actual image, and account for the browser support and fallback behavior your site needs. Keep a format only when it serves a delivery or quality requirement.

Do I need a separate image for every screen size?

No. Use a practical set of candidates that reflects meaningful differences in rendered slot size. More variants can improve matching, but they also increase asset and implementation overhead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.