Best Image Format for Website Speed
WebP is the practical default for most raster images; use AVIF with fallbacks, SVG for vectors, and JPEG or PNG when compatibility or lossless detail matters.
Short answer: Use WebP as the practical default for most raster website images. Offer AVIF first when your browsers and tooling support a reliable fallback. Use SVG for logos, icons, diagrams, and other geometric artwork. Keep JPEG or PNG fallbacks when compatibility, transparency, or precise lossless detail requires them.
Image format is only one part of page speed. Correct dimensions, responsive delivery, compression quality, caching, and loading priority often matter as much as the file extension. The best implementation usually combines modern formats with a <picture> fallback chain and responsive srcset.
Which image format should you choose?
| Image type | Recommended format | Why | Fallback or caution |
|---|---|---|---|
| Photographs and hero images | AVIF or lossy WebP | Usually much smaller than older raster formats at comparable visual quality | Retain JPEG when browser coverage or tooling requires it |
| Screenshots, UI captures, diagrams, line art | Lossless PNG or lossless WebP | Preserves sharp text, edges, and solid-color regions | Test AVIF carefully; artifacts are obvious in fine text |
| Logos, icons, geometric artwork | SVG | Scales without becoming blurry and is often compact for simple shapes | Sanitize, minify, and compress SVG markup |
| Animated images | WebP or AVIF | Often more efficient than GIF | Use APNG when lossless animation is required |
| Transparent raster artwork | AVIF, WebP, or PNG | Supports an alpha channel; PNG remains a dependable lossless option | Check decoder and CDN support before removing PNG |
Google describes WebP as a modern format with superior lossy and lossless compression. MDN recommends WebP or AVIF for raster images because they generally compress better than PNG, JPEG, and GIF. Google’s WebP overview and MDN’s image format guide provide the format-level details.
WebP vs. AVIF
When WebP is the better default
WebP has broad modern browser support, supports lossy and lossless encoding, transparency, and animation, and is usually straightforward to generate and serve. It is a sensible default when you want one modern raster format with a simple fallback.
When AVIF is worth adding
AVIF can compress more aggressively than JPEG or PNG and can also support transparency, animation, and higher color depths. That can reduce transfer size for large photographic images. Support and decoding behavior vary more across older clients and some image pipelines, so serve AVIF with a WebP and JPEG or PNG fallback. The web.dev AVIF guidance covers the support and fallback trade-off.
Compare formats at the dimensions your visitors actually receive. A smaller AVIF with visible banding or ringing is worse than a slightly larger WebP that looks clean. Quality numbers are encoder-specific, so validate your own images rather than copying a universal setting.
PNG, JPEG, and SVG: when the older formats are right
JPEG
JPEG remains a useful, widely supported choice for photographs when a simple fallback is needed. It does not provide an alpha channel, and repeated editing or aggressive compression can create block artifacts.
PNG
PNG is appropriate when you need lossless reproduction, transparency, or crisp UI detail. It is often larger than WebP or AVIF, especially for photographs, but its predictable decoding and broad support make it a valuable fallback.
SVG
SVG is a vector representation, so it is generally the right choice for logos, icons, charts, and diagrams made from geometric shapes. It stays sharp at different sizes. Do not convert a photograph to SVG; the result will be impractical. Remove unnecessary metadata, minify the markup, and apply your normal security policy before serving externally supplied SVG files.
Serve AVIF and WebP with a fallback
The browser selects the first supported <source>. The final <img> remains the fallback for clients that do not support either modern format.
<picture>
<source
type="image/avif"
srcset="/images/hero-640.avif 640w,
/images/hero-1280.avif 1280w,
/images/hero-1920.avif 1920w"
sizes="(max-width: 700px) 100vw, 1200px">
<source
type="image/webp"
srcset="/images/hero-640.webp 640w,
/images/hero-1280.webp 1280w,
/images/hero-1920.webp 1920w"
sizes="(max-width: 700px) 100vw, 1200px">
<img
src="/images/hero-1280.jpg"
srcset="/images/hero-640.jpg 640w,
/images/hero-1280.jpg 1280w,
/images/hero-1920.jpg 1920w"
sizes="(max-width: 700px) 100vw, 1200px"
width="1280"
height="720"
alt="Description of the photograph"
fetchpriority="high"
decoding="async">
</picture>
Use loading="lazy" for images below the fold. Keep fetchpriority="high" for the actual Largest Contentful Paint candidate only. Always provide intrinsic width and height (or an equivalent aspect-ratio rule) to prevent layout shifts.
Responsive images and dimensions
- Start with the rendered dimensions, not the source file’s dimensions. A 4000-pixel image displayed at 600 pixels wastes bandwidth.
- Generate a small set of widths around the layouts you support, such as 640, 1280, and 1920 pixels.
- Use
srcsetwith width descriptors andsizesthat describe the CSS layout. - Do not upscale a source to satisfy a larger descriptor; generate a genuinely larger asset.
- Set cache headers for immutable, content-hashed files so repeat views avoid another download.
web.dev connects efficient image encoding and delivery to download time and Largest Contentful Paint, and recommends modern formats with fallbacks through <picture>. See Choose the right image format and web.dev’s image performance guidance.
Format-specific quality and compression choices
- Photographs: begin with lossy AVIF or WebP, then inspect faces, gradients, foliage, and fine texture at displayed size.
- Text-heavy screenshots: prefer lossless PNG or WebP when compression artifacts make text harder to read.
- Flat illustrations: compare lossless WebP, PNG, and SVG. SVG often wins when the artwork is truly geometric.
- Transparency: verify that the encoder preserves semi-transparent edges and that the browser pipeline does not flatten the alpha channel.
- Animation: compare animated WebP or AVIF with APNG when every frame must remain lossless. Avoid GIF for new work unless a legacy integration requires it.
How to measure whether a format is faster
- Collect representative originals: hero photographs, thumbnails, screenshots, transparent assets, and icons.
- Encode each candidate at the same displayed dimensions and visually acceptable quality.
- Record transfer bytes, decoded dimensions, and whether the browser actually selected the intended source.
- Test on a constrained mobile connection and a normal desktop connection.
- Measure Largest Contentful Paint, total image bytes, and layout stability in a production-like page.
- Keep the format that meets your visual quality target with the lowest delivered cost and acceptable decoding behavior.
Do not judge a format only by the original file size. A responsive 640-pixel image may be faster than a highly compressed 1920-pixel image, and an image that blocks the LCP request deserves a different priority from a decorative image far below the fold.
Capturing screenshots in the right format
When you generate website screenshots for documentation, previews, or monitoring, choose the output format based on what the screenshot contains. WebP is a useful default for ordinary page captures. PNG is safer for pixel-precise UI text, transparency, or downstream editing. JPEG can be smaller for photographic pages when lossless detail is not required. If you need multiple variants, capture once at the required viewport and convert or resize deliberately rather than repeatedly recompressing.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One request returns PNG, JPEG, WebP, or PDF, so you can choose the format that fits your delivery pipeline without maintaining a browser worker.
With ScreenshotNeo, cookie and consent banners are accepted and removed before capture, along with more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server lets Claude, Cursor, and other MCP clients call take_screenshot, get_page_info, and capture_pdf.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const image = Buffer.from(await res.arrayBuffer());
await fs.promises.writeFile('shot.webp', image);
See the ScreenshotNeo API documentation for the request parameters. The service also supports full-page capture with lazy images loaded, CSS selector element capture, dark mode, device presets and custom viewports, retina scale, custom CSS and JavaScript, clicks, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification.
Free accounts include 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots, and every feature is available on every plan. Create a free ScreenshotNeo account.
Troubleshooting
The AVIF or WebP source is never selected
Check the type value, response Content-Type, and the browser’s network panel. The server must return image/avif or image/webp, not a generic binary type. Confirm that a service worker or CDN is not rewriting the response.
The image is smaller but looks worse
Raise the encoder quality, switch to lossless WebP or PNG for text and line art, or deliver a larger source at the same quality. Inspect the image at its rendered size and on a high-density display.
Transparent edges have halos
Check how the source was matted before encoding. Re-export against transparency, avoid a background-colored matte, and verify alpha handling in the chosen encoder and browser.
The page became slower after adding responsive variants
Inspect which candidate was downloaded. An incorrect sizes value can make the browser choose an unnecessarily large file. Also check that preload hints and fetchpriority are not competing with the LCP image.
SVG is blocked or renders as text
Serve it with image/svg+xml, ensure the markup is valid, and check your content security policy. Sanitize untrusted SVG before publishing it.
A ScreenshotNeo capture returns an unexpected page
Use a selector wait or network-idle wait for client-rendered content, set a viewport or device preset that matches the target, and use custom headers, cookies, or authorization when the page requires them. Check X-Page-Verdict and X-Billed to understand whether the response was clean, blocked, blank, failed, or served from cache.
Performance, reliability, and cost checklist
- Choose AVIF or WebP for raster images, with a JPEG or PNG fallback where needed.
- Use SVG for geometric artwork and optimize its markup.
- Generate only the dimensions your layouts request.
- Set width and height, lazy-load below-the-fold images, and reserve priority for the LCP candidate.
- Measure bytes, visual quality, decoding behavior, and LCP on representative devices.
- Cache immutable assets and give generated variants stable URLs.
- For automated screenshots, account for browser startup, waits, retries, and failed navigations in your own system. ScreenshotNeo avoids billing for bot checks, blank pages, timeouts, failed loads, and cache hits.
FAQ
Is WebP faster than JPG?
Often, because WebP can deliver similar visual quality in fewer bytes, but the result depends on the image, encoding settings, dimensions, and browser decode path. Measure the actual page.
Should I use AVIF or WebP?
Use AVIF when its smaller files justify the fallback and tooling complexity. Use WebP as the simpler broad modern default, and serve both when practical.
Is PNG or SVG better for a logo?
SVG is generally better for a logo built from vector shapes because it scales cleanly. Use PNG when the artwork is raster or the consuming system cannot accept SVG.
Can one image format work for every asset?
No. Photos, screenshots, transparent graphics, animations, and geometric artwork have different requirements. A small format policy is more reliable than forcing every asset into one format.
Does changing the extension convert an image?
No. The bytes and the server’s content type must match the format. Re-encode the image and verify the response header.


