Performance April 2026 · 10 min read

How to Optimize Images for Web Performance

Images account for the majority of page weight on most websites. Getting this right is the single highest-leverage performance improvement you can make.

Why Image Optimization Matters for SEO

Google uses Largest Contentful Paint (LCP) — usually an above-the-fold image — as a Core Web Vital. A slow LCP directly hurts your search ranking. Studies consistently show that every 100ms of page load delay reduces conversions by ~1%. Images are often the easiest and biggest win.

Step 1: Choose the Right Format

WebP — Your Default Choice

WebP delivers 25–35% smaller file sizes than JPEG or PNG at equivalent quality, with support in all modern browsers (96%+ global coverage as of 2026). Use it for nearly everything.

AVIF — The Future

AVIF offers another 20–30% reduction over WebP. Browser support is now at ~92%. If your audience is modern, AVIF is worth testing.

PNG — Only When You Need Lossless

Use PNG for images that require pixel-perfect lossless quality — logos with sharp edges, screenshots with text, icons. Never use PNG for photographs.

SVG — For Vector Graphics

Icons, logos, and illustrations that can be described mathematically should always be SVG. They scale infinitely, can be styled with CSS, and are typically tiny. Always run SVGs through an optimizer — raw SVG from Figma or Illustrator contains enormous amounts of unnecessary markup.

FormatBest ForLossy?Transparency?
WebPPhotos, UI imagesBothYes
AVIFPhotos (modern target)BothYes
PNGScreenshots, losslessNoYes
JPGLegacy photos onlyYesNo
SVGIcons, logos, illustrationsN/AYes

Step 2: Compress Aggressively

The sweet spot for JPEG/WebP quality is 75–85%. Going lower produces visible artifacts; going higher produces diminishing returns with larger file sizes. For most photography, 80% quality looks identical to 100% at a fraction of the size.

You can compress images directly in your browser — no uploads, total privacy — using StudioLimb's Image Compressor.

Step 3: Resize to Display Dimensions

Never serve a 4000×3000px image in a 400px wide column. The browser has to download and decode every single pixel even if it only displays a quarter of them. Rule of thumb: serve images at 2× the CSS pixel dimensions (for HiDPI/Retina screens).

<img
  src="hero.webp"
  width="800"
  height="450"
  alt="Dashboard screenshot"
  loading="lazy"
  decoding="async"
/>

Step 4: Use Lazy Loading

Add loading="lazy" to any image below the fold. This is a native browser attribute — no JavaScript required. The browser won't fetch the image until the user scrolls near it, saving bandwidth for users who never scroll that far.

Exception: Never lazy-load your hero image or any image that appears in the initial viewport. That will hurt LCP.

Step 5: Always Add Explicit Width and Height

Setting width and height attributes on <img> tags prevents Cumulative Layout Shift (CLS) — another Core Web Vital. The browser reserves the correct space before the image loads, so the page doesn't jump around.

Step 6: Use the <picture> Element for Art Direction

Serve AVIF with WebP fallback, and different crops for mobile vs desktop:

<picture>
  <source srcset="hero-mobile.avif" media="(max-width: 640px)" type="image/avif">
  <source srcset="hero-mobile.webp" media="(max-width: 640px)" type="image/webp">
  <source srcset="hero.avif" type="image/avif">
  <source srcset="hero.webp" type="image/webp">
  <img src="hero.jpg" alt="Hero image" width="1200" height="630">
</picture>

Step 7: Optimize SVGs

Raw SVG exported from design tools contains enormous amounts of unnecessary markup — editor metadata, redundant attributes, unnecessary precision. Run every SVG through StudioLimb's SVG Optimizer before deploying. Savings of 40–70% are common.

Step 8: Preload Your Hero Image

Your LCP element — usually the hero image — should be discovered and fetched as early as possible. Add a <link rel="preload"> in the <head> to tell the browser to start downloading it immediately, before it parses the HTML body:

<!-- In <head>, before stylesheets -->
<link
  rel="preload"
  as="image"
  href="hero.webp"
  imagesrcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
  imagesizes="100vw"
/>

This is one of the highest-leverage LCP improvements available. Without it, the browser discovers the hero image only after parsing the HTML, rendering CSS, and potentially executing JavaScript — adding hundreds of milliseconds to LCP.

Step 9: Responsive Images with srcset and sizes

Serving a 1200px wide image to a phone with a 390px screen wastes bandwidth and slows loading. The srcset and sizes attributes tell the browser which image to download based on screen width:

<img
  src="photo-800.webp"
  srcset="
    photo-400.webp  400w,
    photo-800.webp  800w,
    photo-1200.webp 1200w,
    photo-1600.webp 1600w
  "
  sizes="
    (max-width: 640px)  100vw,
    (max-width: 1024px) 80vw,
    1200px
  "
  alt="Team photo"
  width="1200"
  height="630"
  loading="lazy"
/>

How to read sizes: The browser reads left to right and stops at the first matching condition. On screens under 640px, the image fills 100% of the viewport width, so the browser picks an appropriately sized source from srcset. On screens under 1024px, it fills 80vw. Otherwise, it's a fixed 1200px. This dramatically reduces the image size downloaded on mobile devices.

Real-World File Size Comparison

To illustrate the impact of format choice and compression, here's a real comparison of the same 1200×800px photograph across formats:

FormatQualityFile Sizevs. JPG
JPG85%~320 KBbaseline
JPG75%~190 KB−41%
WebP85%~200 KB−37%
WebP75%~130 KB−59%
AVIF75%~95 KB−70%
WebP lossless~480 KB+50%
PNG~650 KB+103%

The takeaway: WebP at 75–80% quality is the safe default. AVIF offers dramatic savings but requires the <picture> element for fallback support.

Common Image Optimization Mistakes

1. Lazy-loading the hero/LCP image

This is the single most damaging mistake for Core Web Vitals. Adding loading="lazy" to your above-the-fold hero image delays its download until after the page renders — the opposite of what you want. Never lazy-load images that appear in the initial viewport.

2. Serving retina images to everyone

A 2× retina image is 4× the pixels (and roughly 2–3× the file size) of a standard image. Always use srcset to serve 2× images only to devices that need them. Phones with 1× displays (still common globally) get the smaller version.

3. Not setting width and height on images

Without explicit dimensions, the browser doesn't know how much space to reserve before the image loads. As the image downloads, the page jumps — causing Cumulative Layout Shift (CLS), which tanks your Core Web Vitals score and frustrates users mid-read.

4. Using PNG for photographs

A photograph saved as PNG is typically 3–5× larger than the same image in WebP or JPEG. PNG's lossless compression provides zero visible quality benefit for photographic content — the format simply wasn't designed for it.

5. Forgetting to optimize SVGs

SVG exported from Figma, Illustrator, or Sketch contains enormous metadata, unnecessary decimal precision, and editor-specific markup. An "optimized" SVG icon from a raw export might be 12KB; after running through StudioLimb's SVG Optimizer, the same icon is often 2–4KB.

6. Not testing on slow connections

Optimize with throttling enabled in DevTools (Network tab → Slow 3G or Fast 3G). What looks fast on your fiber connection may be a 10-second wait on a mobile network. Your image choices look very different when you actually simulate what most users experience.

Quick Checklist

Frequently Asked Questions

What's a good target file size for web images?

A good rule of thumb: hero images under 150KB, content images under 80KB, thumbnails under 30KB. These aren't hard rules — a 200KB hero is fine if it's properly lazy-loaded and isn't your LCP element. The real target is LCP under 2.5 seconds in Google's Core Web Vitals measurement.

Should I use an image CDN?

For high-traffic sites, yes. CDNs like Cloudflare Images, Imgix, or Cloudinary can automatically serve WebP/AVIF, resize on-the-fly, and cache images at edge nodes globally. For low-traffic sites or static sites, manual optimization with StudioLimb's tools is sufficient and has no monthly cost.

Does image optimization affect SEO?

Directly, yes. Google uses LCP (usually the hero image) as a Core Web Vital ranking signal. A faster LCP means better rankings. Google also reads alt attributes for indexing — always write descriptive, specific alt text rather than leaving it empty or using file names.

How often should I re-optimize images?

Any time you update images or add new ones. If you're using a static site, make optimization part of your deployment checklist. If you're using a CMS, set up an automatic compression pipeline at upload time so you never have to think about it manually.

Related Guides

compress

Image Compressor

Browser-based, private

transform

Format Converter

WebP, PNG, JPG

cleaning_services

SVG Optimizer

Remove bloat from SVG