How to Optimize Images for the Web (Without Losing Quality)
A step-by-step workflow for smaller images that still look sharp: resize, pick a format, compress, strip metadata, and serve from a CDN with the right caching headers.
Images are usually the heaviest thing on a web page. Fixing that is not about making pictures look worse — it's about removing bytes nobody can see. Follow these steps in order and you'll typically cut image weight by 50–80% with no visible difference.
Why it matters
Page speed affects everything: rankings, conversion, and whether someone on a train with two bars of signal waits for your page or leaves. The largest element on most pages is an image, and it's measured directly by the Largest Contentful Paint (LCP) metric. Shrinking that image is the highest-leverage performance fix available to most sites.
Step 1: Resize to the size you actually display
This is the biggest and most commonly skipped win. A 4000-pixel-wide photo displayed at 800 pixels is wasting 80% of its data. Before anything else, scale the image down to roughly twice its display width (a 2× buffer for high-density screens).
- Full-width hero image on a 1440px layout → export at about 2000px wide.
- Article body image → 1200px wide is generous.
- Thumbnail or avatar → export at the exact size it renders, times two.
Step 2: Pick the right format
Use WebP for almost everything on the web. For photographs, JPEG is an acceptable fallback. Keep PNG for logos, icons, and anything with text or transparency. Reserve GIF for cases where compatibility genuinely requires it. If you want the full reasoning, see ourformat comparison guide.
Step 3: Compress deliberately
Quality settings are not linear. Going from quality 100 to 80 usually removes a third of the file size with no perceptible change. Going from 80 to 60 starts to show. A pragmatic default:
- Photographs: quality 75–85.
- Screenshots and UI: quality 85–90, or lossless if the file is small.
- Line art and logos: lossless, and consider SVG where possible.
Always compare at 100% zoom rather than fit-to-window. Compression artifacts hide at small sizes and become obvious when someone clicks the image.
Step 4: Strip metadata
Photos from phones and cameras carry EXIF data: camera model, timestamps, and often GPS coordinates. It can add tens of kilobytes, and the location data is a genuine privacy risk. Almost every image editor has a "remove metadata" or "export for web" option — use it.
Step 5: Serve it fast
The file being small is half the job; the other half is delivering it efficiently. Two things matter:
- A CDN. A global edge network keeps the image physically close to the visitor. imgbb serves every upload from Cloudflare's edge.
- Immutable caching. If the URL never changes, the file can be cached aggressively. imgbb sends
Cache-Control: public, max-age=31536000, immutablefor image responses, so repeat visits cost nothing.
Step 6: Let the browser do less work
Two attributes on your <img> tags pay for themselves immediately:
loading="lazy"— defers offscreen images until the visitor scrolls near them. Don't lazy-load the hero image; load that one eagerly.widthandheight— lets the browser reserve space before the image arrives, which prevents layout shift (CLS). It's the cheapest accessibility and stability win there is.
Step 7: Write alt text
Alt text isn't an optimization in the byte sense, but it's part of doing images properly on the web. It's read by screen readers, shown when an image fails to load, and used by search engines to understand the content. One clear sentence describing what's in the image is enough — skip "image of" and keyword stuffing.
Recommended tools
- Squoosh — browser-based, no install, side-by-side compression comparison.
- ImageMagick — command-line workhorse for batch resizing and conversion.
- Sharp — the Node.js library behind many build pipelines; great for automation.
- Your editor's "export for web" — usually enough for a handful of images.
The before/after checklist
- Resized to roughly 2× display width?
- Converted to WebP (or JPEG for photos)?
- Compressed at quality 75–85 and checked at 100%?
- Metadata stripped?
- Served from a CDN with long-lived cache headers?
- Offscreen images lazy-loaded, hero image eager?
- Width and height set to prevent layout shift?
- Alt text written?
Frequently asked questions
Does compression hurt SEO?
The opposite. Smaller images improve page speed, which improves Core Web Vitals and rankings. What can hurt is stripping alt text or serving images at the wrong dimensions.
Should I use SVG instead?
For logos, icons, and simple illustrations, SVG is ideal — it's resolution-independent and tiny. It doesn't work for photographs. Note that imgbb hosts raster formats (JPEG, PNG, WebP, GIF), not SVG.
How small is small enough?
As a rule of thumb: hero images under 200 KB, article images under 100 KB, thumbnails under 30 KB. Hit those and your page will feel instant on a normal connection.
Ready to host your images?
Upload in seconds and get direct links, HTML, BBCode, and Markdown — no account needed.
Upload an image