← Back to Blog

How to optimize images for the web without losing quality

Images are typically the largest files on any webpage. Unoptimized images slow down your site, hurt your search rankings, and frustrate visitors. Here's a practical approach to getting images right for the web.

Original PNG 4.2 MB 96% smaller Optimized WebP 210 KB
A 4.2 MB PNG hero image saved as WebP at 80% quality: 210 KB — a 96% reduction with no perceptible quality loss.

Why image optimization matters

Google uses page speed as a ranking factor, and images are usually the biggest contributor to slow load times. A single uncompressed photo from a modern smartphone can be 5–10MB. The same photo, properly optimized for web, should be under 200KB — a reduction of 95% with barely any visible difference.

Beyond SEO, faster pages mean better user experience. Studies consistently show that pages loading in under 2 seconds have significantly lower bounce rates than slower pages.

Step 1: Choose the right format

Format choice is the most impactful decision you can make. As a general rule:

Quick win: Converting your site's JPG images to WebP alone can reduce image weight by 25–35% with no visible quality change.

Step 2: Resize to the right dimensions

There's no point serving a 4000×3000px image when it's displayed at 800×600px on screen. The browser has to download all those extra pixels and then scale them down — wasting bandwidth and time.

Before uploading any image to your website, resize it to the maximum size it will be displayed at. For most blog post images, 1200px wide is more than enough. For thumbnails and cards, 400–600px is often sufficient.

Rule of thumb: Your image dimensions should be no more than 2× the display size (to account for retina/HiDPI screens).

Step 3: Compress without losing quality

After resizing, compress the image to reduce file size further. The key is finding the right balance between quality and file size. For most web images:

A practical workflow for web images

  1. Start with the original high-quality source file
  2. Resize to the maximum display size (e.g. 1200px wide for blog posts)
  3. Convert to WebP if your website supports it
  4. Compress with quality set to 75–80%
  5. Check the file size — aim for under 200KB for most images, under 100KB for thumbnails
  6. Upload and test your page speed

What file size should you target?

The impact of image weight on Core Web Vitals

Google's Core Web Vitals are performance metrics that directly influence search rankings, and images are their biggest single lever. Two metrics are especially affected by how you handle images:

Largest Contentful Paint (LCP) measures how quickly the largest visible element on the page loads. In most cases that element is a hero image or banner photo. Google's threshold for a "good" LCP score is under 2.5 seconds. A 5 MB hero image on a typical mobile connection will blow past that limit; the same image compressed and converted to WebP at 180 KB will comfortably pass it.

Cumulative Layout Shift (CLS) measures visual stability. When images load without predefined dimensions, the surrounding content shifts as images appear — an experience Google penalizes in rankings. The fix is simple: always include width and height attributes on your <img> tags so the browser can reserve the correct space before the image loads, regardless of how fast or slow the connection is.

To put real numbers on it: a 5 MB hero image resized and converted to WebP at 80% quality becomes approximately 180 KB — a 96% reduction. On a 10 Mbps mobile connection, that's the difference between a 4-second image load and a 0.14-second one. Image optimization is the single highest-impact change most websites can make to their Core Web Vitals scores.

Lazy loading: defer what the user can't see yet

HTML5's loading="lazy" attribute tells the browser to skip loading an image until it is about to enter the viewport. This means your page's initial load only fetches images that are actually visible — everything else waits until the user scrolls near it. Adding lazy loading to below-the-fold images is a one-attribute change with no visual downside:

Syntax: <img src="photo.webp" loading="lazy" width="800" height="600" alt="Description">

One critical exception: do not use loading="lazy" on hero images or any content visible on first load. Those images need to start downloading immediately — deferring them would hurt your LCP score. Apply lazy loading to images in the article body, product grids, related-posts sections, and footers. Browser support is universal across all modern browsers (Chrome, Firefox, Safari, Edge) with no JavaScript or polyfills required.

Set the right dimensions before you compress

One of the most common image optimization mistakes is uploading a large image and relying on CSS to make it appear smaller on the page. For example, setting max-width: 700px in CSS controls how the image is displayed — but the browser still downloads every pixel of the original file and then scales it down in memory. A 4000 × 3000 px image displayed at 700 × 525 px wastes roughly 97% of its pixels.

Always resize your image to the actual display size — or at most 2× the display size to account for retina and HiDPI screens — before uploading. For a blog post image displayed at 700 px wide, serve an image that is 1400 px wide. For a product thumbnail at 300 px, serve a 600 px image. Never let CSS do the work that image resizing should have done before upload.

A real-world example: a 5 MB smartphone photo resized to 1400 px wide, then converted to WebP at 80% quality, becomes approximately 180 KB — a 96% reduction with no perceptible quality loss at any screen size the image will realistically be displayed at. That is the impact of combining resize and compress together.

Frequently asked questions

What is the best image format for websites in 2026?
WebP is the best choice for most web images — it delivers smaller file sizes than JPG and PNG at comparable quality, supports transparency, and is supported by all modern browsers. For logos and icons, SVG is even better when the artwork is vector-based, since it scales perfectly at any size with minimal file weight. For contexts that require broad compatibility such as email attachments or some third-party uploads, JPG remains the safest fallback format.
How much should I compress images without losing quality?
For JPG and WebP, a quality setting of 75–85% is the sweet spot for web images. At 80% quality, file sizes are typically 40–60% smaller than at 100%, with differences that are nearly invisible at normal viewing sizes on most displays. Dropping below 70% starts introducing visible compression artifacts, especially around text, sharp edges, and areas of high contrast. For PNG, compression is always lossless, so image quality never degrades — only the encoding efficiency and file size change based on the compression level you choose.
Does image size affect SEO?
Yes, significantly. Google uses Core Web Vitals — including Largest Contentful Paint (LCP) — as ranking signals. Large, unoptimized images are the single biggest contributor to poor LCP scores. A page with a 5 MB hero image will almost certainly fail Google's performance thresholds; the same page with a properly optimized 180 KB WebP version will pass. Image optimization is one of the most effective ways to improve search rankings without changing any written content on the page.
What is lazy loading and should I use it?
Lazy loading defers image loading until the image is about to enter the visible viewport, so the browser's initial page load only fetches what the user can actually see. You enable it with loading="lazy" on your <img> tags — no JavaScript required. Use it on all images that appear below the fold, including body images, product grids, and comment-section avatars. Do not use it on hero images or anything visible on first load, as deferring those would hurt your LCP score rather than help it.
Should I use a CDN for images?
Yes, if your site serves significant traffic or has visitors in multiple regions. A CDN (Content Delivery Network) distributes copies of your images to servers around the world so each visitor downloads from a server geographically close to them, rather than your origin server. Many CDNs also offer automatic image optimization — serving WebP to supporting browsers, resizing images dynamically, and applying compression — which can dramatically improve performance without any manual work on individual files. For high-traffic sites, a CDN is often the single biggest performance improvement after basic image compression.
What's the difference between resizing and compressing an image?
Resizing changes the pixel dimensions of an image — for example, from 4000 × 3000 px down to 1400 × 1050 px. Compressing reduces the file size without necessarily changing dimensions, by encoding the image data more efficiently or discarding less-perceptible detail. Both are important and work best together: resize first to eliminate unnecessary pixels, then compress to reduce the encoded data size. Doing only one of these steps leaves substantial file-size savings on the table — a compressed but still oversized image still wastes bandwidth when the browser scales it down in CSS.

Compress and convert your images for free — right in your browser, no upload needed.

Compress images →