Skip to content
Aldrian

Performance2 min read

Image Optimization for Faster Websites

Images are usually the heaviest part of a page. Here's how to size, compress, and serve them so your site loads quickly without looking worse.

Aldrian Loyola

Web developer

Abstract illustration of a photo frame shrinking into a smaller file

When a page feels slow, images are the first place I look. A single photo straight off a phone camera can weigh several megabytes, which is more than the rest of the page combined.

The good news: image optimization is one of the easiest speed wins, and most of it doesn't require touching code.

1. Resize before you upload

If an image will never be shown wider than about 1,600 pixels, there's no reason to upload a 4,000 pixel original. The browser still downloads the full file, then shrinks it.

A simple rule of thumb:

  • Full-width hero images: around 1,600 to 2,000 pixels wide
  • Content images inside an article: around 1,200 pixels wide
  • Thumbnails and cards: 600 to 800 pixels wide

2. Choose a modern format

FormatBest forNotes
WebPPhotos and graphicsWidely supported and usually much smaller than JPEG at similar quality
AVIFPhotosOften smaller still, but slower to encode
JPEGPhotos (fallback)Fine when nothing else is available
PNGLogos, screenshots with sharp textAvoid for photos, files get large
SVGLogos and iconsTiny and sharp at any size

For most business sites, WebP is a safe default for photos.

3. Compress sensibly

Compression removes detail the eye barely notices. A quality setting around 75 to 85 is a good starting point for photos. Compare the before and after at normal viewing size, not zoomed in to 400%.

Tools that help:

  • Squoosh (free, in the browser)
  • Your image editor's "export for web" option
  • WordPress image optimization plugins that convert and compress on upload

4. Let the browser pick the right size

On a phone, there's no need to download the desktop-size image. Responsive images (the srcset and sizes attributes) let the browser choose the smallest file that still looks sharp. WordPress adds these automatically for images inserted through the media library.

5. Lazy-load images below the fold

Images further down the page don't need to load immediately. Adding loading="lazy" tells the browser to wait until the visitor scrolls near them.

One exception: don't lazy-load your main hero image. It's usually the largest visible element, and delaying it makes the page feel slower and hurts Largest Contentful Paint.

6. Always set width and height

When the browser knows an image's dimensions in advance, it reserves the space before the file arrives. Without them, text jumps around as images pop in, which is frustrating for visitors and counts against Cumulative Layout Shift.

7. Don't forget alt text

Alt text isn't a speed tip, but it belongs on every checklist. It describes the image for people using screen readers and gives search engines context. Describe what's in the image and why it's there. Decorative images can have empty alt text.

A quick audit you can do today

  1. Run your homepage through PageSpeed Insights.
  2. Look for opportunities mentioning images ("properly size images", "serve images in next-gen formats").
  3. Fix the biggest files first. The top three are usually responsible for most of the weight.

Small changes here often make a noticeable difference, especially for visitors on mobile data.

Share

Keep reading

Abstract illustration of a shield over a server

WordPress4 min read

PHP2Shell: What WordPress Site Owners Need to Do Now

Two critical PHP flaws disclosed on October 21, 2026 can let attackers take over a server without logging in. Here's how to check if your WordPress site is affected and what to fix first.

Read article