Cut Page Weight: 7 Step Web Image Compression for Design & Dev Teams

Compress images for the web by serving appropriately sized files in modern formats like WebP or AVIF where supported, automating the conversion process, and testing the impact on Core Web Vitals. Aim for hero images at roughly 400 kilobytes or smaller where practical, with supporting images scaled down proportionally. We have applied this approach across many client projects and it consistently makes the biggest difference to loading speed.


TL;DR:

  • Serve images in WebP or AVIF formats with JPEG or PNG fallback, achieving 25 to 50 percent file size reduction without visible quality loss.
  • Resize images to actual display dimensions before compression and generate multiple responsive variants to minimize wasted data on different devices.
  • Use srcset and sizes attributes along with width and height tags to optimize image delivery and prevent layout shifts, especially on mobile devices.
  • Automate image processing with build tools like Sharp or ImageMagick and include metadata stripping and compression in CI/CD pipelines for consistency.
  • Keep hero images around 400 kilobytes or smaller and verify performance improvements with Lighthouse, focusing on transfer bytes and Largest Contentful Paint metrics.

MB Web
web.michaelbell.co.uk
Build A Faster, More Effective Website
MB Web combines web design, development and SEO to help local and national brands improve how their websites perform.

Visit MB Web

A short checklist to get started today

Getting your images sorted does not need to be complicated if you follow the steps in the right order.

  1. Keep your original master files safe before you touch anything.
  2. Resize each image to the actual display size it needs on the page.
  3. Choose a format: WebP or AVIF where supported, with a JPEG or PNG fallback.
  4. Generate two or three responsive variants for different screen widths.
  5. Compress and strip unnecessary metadata from every file.
  6. Lazy load anything below the fold.
  7. Test the result visually and with Lighthouse before publishing.

Resizing before compressing matters because a compressor working on an oversized file wastes effort on pixels nobody will ever see. Many teams now wire these steps into a build script or CI pipeline so nobody has to remember to do it by hand.

Responsive images: srcset, sizes and preventing wasted bytes

The srcset attribute lists several versions of the same image at different widths, and sizes tells the browser how much space the image will occupy in the layout. Together, they let the browser pick the smallest file that still looks sharp on that particular screen, rather than downloading a desktop-sized file on a phone.

That matters more than it sounds. Serving a desktop-sized image to a mobile visitor can use 2 to 4 times more data than necessary, which is a real cost for anyone on a limited mobile connection.

  • Start with 3 to 5 width variants per image as a practical baseline.
  • Use <picture> when you need a genuinely different crop or composition for mobile, not just a smaller version of the same image.
  • Always set width and height attributes so the browser can reserve space before the image loads.

Pro Tip: Setting width and height does not stop responsive sizing working. It simply stops the page jumping around while images load, which protects your layout stability score.

Modern formats: WebP and AVIF trade-offs and fallback strategies

Web Design Sussex | 1791092436615 Image formats branching to browser fallbacks 1

WebP has broad browser support now and typically shrinks files by 25 to 35% compared with an equivalent JPEG, with no visible quality loss in most photographic content. AVIF often goes further, sometimes delivering savings above 50% versus JPEG, though encoding takes longer and support, while improving, is not universal.

The safest approach is to serve AVIF or WebP with a JPEG or PNG fallback using the <picture> element, so older browsers simply fall back to a format they understand. Server-side content negotiation using the Accept header is an alternative if your hosting setup supports it.

  • cwebp converts images to WebP from the command line.
  • avifenc, built on libraries such as libavif and libaom, handles AVIF conversion.
  • Squoosh gives a visual, in-browser way to compare formats and quality side by side before committing to settings in a pipeline.

Compression settings and perceptual testing: pick quality that hides artefacts

Lossy compression discards some image data permanently and suits photographs, where a small amount of detail loss is invisible to the eye. Lossless compression keeps every pixel intact and suits logos, line art and screenshots with flat colour and sharp edges, where artefacts are obvious.

As a starting point, JPEG quality settings between 50% and 80% work well for most photographic content, though the right figure depends entirely on the image. Treat any number as a starting point, not a rule: the professional habit is to compress until you can only just notice a difference, then back off one step.

  • Strip EXIF metadata, which adds weight without adding anything a visitor needs.
  • Use progressive JPEG encoding for larger images so they render gradually rather than appearing line by line.
  • Check results both with Lighthouse and with your own eyes, because a tool score does not catch every visible artefact.

Converting a large JPEG to AVIF at sensible quality settings can meaningfully cut transfer size and help the page’s Largest Contentful Paint, which is one of the clearest wins available from format choice alone.

Automation and delivery: build a pipeline or use an image service

Build-time tools such as Sharp and ImageMagick resize and convert images as part of your deployment process, so every image is handled consistently before it ever reaches a visitor. On-the-fly image services and CDNs do the same job at request time, which saves setup effort but adds a dependency and a recurring cost.

  • Generate responsive width variants automatically rather than by hand.
  • Convert to modern formats with fallbacks as a build step.
  • Strip metadata and apply compression settings consistently across every image.
  • Run these steps in CI/CD so a missed step never reaches production.

Build-time pipelines suit teams with predictable image libraries; a managed image service suits sites publishing large, unpredictable volumes of new images where engineering time is the scarcer resource.

Accessibility and SEO safeguards when you compress images

Performance work should never come at the cost of usability. Accurate alt text is required for informative images, and purely decorative images should be marked so screen readers skip them rather than announcing something meaningless. Important text belongs in HTML, never baked into a bitmap, because it becomes invisible to screen readers and impossible to translate or resize.

  • Write alt text that describes the image’s purpose, not just its contents.
  • Mark decorative images so assistive technology ignores them.
  • Keep width and height set, and use fetchpriority="high" or a preload hint on your main hero image to help it load sooner.

Pro Tip: After compressing, zoom into any image containing text or fine detail at 100% to confirm nothing has turned muddy or blocky.

Verify and measure: setting sensible file-size targets

Measuring the result is what separates a genuine improvement from a guess. The two numbers worth watching are total transfer bytes and Largest Contentful Paint, and modern formats, responsive sizing, preload hints and lazy loading all feed directly into both.

  1. Run Lighthouse before and after your changes and compare the scores directly.
  2. Open the network waterfall in your browser’s developer tools to see exactly which image is the heaviest.
  3. Set a rough target, such as keeping hero images around 400 kilobytes or smaller, and work other page images down proportionally.
  4. Add an automated size check to your CI pipeline so a regression gets caught before it ships, not after.

How we apply these principles

We have spent years building and maintaining websites for businesses across the South East, and image optimisation is integrated as a routine part of website builds rather than an afterthought bolted on later. A typical scenario: a client site arrives with full-resolution camera photos dropped straight into the CMS, and resizing, converting and lazy loading them brings a visible drop in page weight without any change to how the images look. We incorporate this work into web design and website maintenance services, so optimisation continues quietly after launch rather than only at the start.

— James Golding

When to favour fidelity over file size

A booking form or product page justifies a slightly larger, sharper image if it genuinely helps the visitor decide. A gallery or portfolio page, by contrast, should lean hard towards smaller files, because visitors are browsing many images at speed and will not forgive slow loading. Test perceptually, and spend your fidelity budget where it changes a decision, not everywhere equally.

How we can help with image optimisation and performance

We build image optimisation into the way we design and maintain websites, so you are not left trying to manage pipelines and formats on your own. If performance has become a recurring headache, we would rather talk honestly about what is actually slowing your site down than sell you something you do not need.

  • Web Design builds performance and responsive images into the site from the first wireframe.
  • Website Hosting from £350 per year can carry optimised delivery as part of the package, with extra 10GB bolt ons at £35 per year for larger media libraries.
  • Website Maintenance and Updates keeps new images compressed properly as your site grows, so performance does not quietly slip over time.

If you would like a straight answer on what is slowing your site down, get in touch and we will talk it through.

FAQ

What is the best website image compressor?

There is no single best tool for every job: Squoosh is a strong free option for comparing formats visually, while cwebp and avifenc suit automated pipelines. The right choice depends on whether you need a one-off manual check or a repeatable build step.

How do I compress an image online?

Upload the image to a browser-based tool such as Squoosh, choose a format like WebP or AVIF, adjust the quality slider while watching the preview, and download the result. Always compare the compressed version against the original at full size before using it.

What is the best compression method for images?

Lossy compression suits photographs because small amounts of discarded detail are invisible to the eye, while lossless compression suits logos and line art where every edge needs to stay sharp. Testing perceptually, rather than fixing on one quality number, gives the most reliable result across different image types.

How do I compress an image in HTML?

HTML itself does not compress images: you compress the file beforehand, then reference the optimised version with the <img> tag, ideally alongside srcset for responsive sizing. Setting width, height and, for key images, fetchpriority="high" helps the browser load and display it efficiently.

Does image compression affect SEO?

Smaller, well-optimised images improve loading speed, which is one factor search engines weigh through metrics such as Largest Contentful Paint. Compression has no direct effect on rankings beyond that, so accurate alt text and sensible file names still matter just as much.

Sources