How to compress images for a website

A practical guide · Updated June 2026

Images are usually the heaviest thing on a web page — often more than the HTML, CSS and JavaScript combined. Compressing them well is the single highest-impact thing most people can do to make a site faster, and it takes minutes, not hours. This guide walks through why bloated images slow you down, how compression actually works, and the exact settings, formats and file-size targets that keep pages fast without any visible loss of quality.

Why large images slow your site down

Every image on a page has to travel from a server to a visitor's device before it can be drawn on screen. A 3MB photo on a mobile connection can take several seconds to arrive, and while it loads the page looks broken or empty. That delay hurts you in three concrete ways:

The good news: an image compressed correctly can be 60–80% smaller than the original with no difference the human eye can spot. That is essentially free performance.

How image compression actually works

There are two families of compression, and knowing the difference tells you which setting to reach for.

Lossy compression

Lossy compression permanently discards data the eye is unlikely to notice — subtle colour variations, fine detail in busy areas — in exchange for dramatically smaller files. JPG and lossy WebP work this way. You control how aggressive it is with a quality slider. This is what you want for photographs and most website imagery, because photos have so much detail that removing a little is invisible.

Lossless compression

Lossless compression rearranges and packs data more efficiently without throwing anything away, so the result is pixel-perfect. PNG and lossless WebP work this way. The savings are smaller, but the image is identical to the original. Use it for logos, icons, screenshots with sharp text, and anything with hard edges or transparency where lossy artifacts would show.

A simple decision: photos → lossy, graphics with crisp lines → lossless. Most pages are a mix, so you will use both.

Choosing the right quality setting

When you compress with a quality slider, the sweet spot for the web is 70–85%. Inside this band files shrink enormously while the difference stays invisible at normal viewing sizes. Here is what actually happens as you move the slider:

A reliable habit is to start at 80%, look at the result at full size, and only drop lower if the file is still too big. Never re-compress an already-compressed JPG repeatedly — each save loses a little more, and the damage stacks up. Always compress from the highest-quality original you have.

Resize to display size before you compress

This is the step most people skip, and it is often worth more than the compression itself. Cameras and phones produce images 4000–6000 pixels wide, but a blog body is rarely wider than 800 pixels and a thumbnail might display at 200. Serving a 4000px image into an 800px slot means the browser downloads roughly five times more pixels than it can ever show and then throws the rest away.

So the correct order is resize first, then compress:

  1. Find the widest the image is ever shown on your site (check the layout — content column, card, thumbnail).
  2. Resize the image to that width. For sharp displays, exporting at roughly 1.5–2× the display width keeps it crisp on retina screens without going overboard.
  3. Then apply 70–85% quality compression to the correctly-sized file.

As a quick reference for common slots:

Pick the right format — usually WebP

Format choice compounds the savings from quality and resizing. For most modern sites the answer is WebP: at the same visual quality it is typically 25–35% smaller than JPG and far smaller than PNG, it supports transparency, and every current browser handles it. Convert your JPGs and PNGs to WebP and you often cut page weight by another third for free.

If you are unsure which format a specific image should be, our image converter lets you try each one and compare the resulting file sizes in seconds.

Target file sizes to aim for

Numbers make this concrete. If you hit these targets, your pages will feel fast on almost any connection:

If a single image blows past 500KB after compression, it almost always means the dimensions are still too large — go back and resize before compressing harder.

A fast batch workflow

You rarely have just one image. Here is a repeatable process that scales from a single post to an entire gallery:

  1. Gather the originals at the highest quality you have — never work from screenshots or already-shrunk copies.
  2. Resize each image to its display width using the reference sizes above. Many tools let you set a maximum width and process a whole folder at once.
  3. Convert to WebP (or AVIF) for the biggest format win.
  4. Compress at 80% quality, then spot-check the largest files at full size.
  5. Verify the totals — confirm no image exceeds its target and the page as a whole stays under 1–2MB.

Do this once for a template and every future image just follows the same recipe. It becomes a two-minute habit rather than a project.

Keep it private: compress in your browser

Many online compressors upload your images to a server to process them, which means your photos leave your device and sit on someone else's machine. That is a privacy and security concern for client work, personal photos, or anything confidential. The better option is a client-side tool that does everything in your browser — the image is processed locally and never uploaded anywhere.

Benefits of a client-side, in-browser approach:

All of Imagloo's tools work this way — the processing happens on your device, and nothing is sent to us.

Frequently asked questions

What is the best file size for website images?

As a rule of thumb, keep full-width hero images under 200KB, in-content photos under 100KB, and thumbnails under 50KB. Aim for a total page weight below 1–2MB. These are targets, not hard limits — a large, detailed hero may need a little more, but if a single image is over 500KB it almost always has room to be compressed or resized.

Is it better to compress or resize an image first?

Resize first, then compress. Shrinking the pixel dimensions to the size the image is actually displayed removes the most wasted data, because a 4000px photo shown in a 800px slot is carrying five times more pixels than the screen can use. Once the dimensions are right, apply quality compression to squeeze out the rest.

Does compressing images hurt SEO?

No — done correctly it helps SEO. Compression reduces page weight and improves loading speed, which is a direct ranking factor through Core Web Vitals such as Largest Contentful Paint. As long as you keep quality in the 70–85% range and size images to their display dimensions, the visual difference is negligible while the speed and ranking benefits are real.

Try the free tools — in your browser

Put this guide into practice with Imagloo's free, private tools. Everything runs locally in your browser, so your images are never uploaded: