← All image guides

By the ImageOpti team ·

Image Workflow for Developers: Formats, Sizes, CWV

A repeatable image workflow for developers: pick formats, size for breakpoints, compress, and protect LCP and CLS, with free browser tools.

Images tend to be the largest resources on a page and the most frequent cause of a poor Largest Contentful Paint (LCP) or Cumulative Layout Shift (CLS). The fix is rarely one clever trick. It is a short, repeatable pipeline that every image passes through before it ships.

This guide lays out that pipeline for developers and designers: export at the right size, convert to a modern format, compress against a budget, serve responsively, and verify. For one-off batches and small sites, the steps can be done with free in-browser tools, with no build step and no uploads. For larger projects, the same logic maps onto whatever build tooling you already use.

The pipeline at a glance

  1. Size. Export at the dimensions the layout needs.
  2. Format. Convert to a modern format, keeping a fallback.
  3. Compress. Hit a per-image budget.
  4. Serve. Use responsive markup, explicit dimensions and sensible loading.
  5. Verify. Measure in lab and field data.

Step 1: Size for breakpoints and density

Start from the largest displayed size at each breakpoint. If a card is 400 CSS pixels wide on desktop and full width (say 390) on a phone, an image around 800 pixels wide covers both, including 2x displays. A hero spanning 1440 CSS pixels may need 1600 to 2000 pixels at most; going to 3x on every image multiplies bytes for a benefit few people can see.

Plan two or three widths per image rather than a dozen: for example 480, 960 and 1600. Then let the browser pick. Resizing a folder to a single width is quick with the bulk image resizer, which processes the batch in your browser and returns a ZIP. Run it once per target width.

Never enlarge to hit a size. If the source is smaller than a breakpoint needs, re-export from the design file or accept a smaller slot.

Step 2: Choose formats and fallbacks

A pragmatic strategy: ship AVIF or WebP, with JPEG or PNG behind them for anything that cannot decode the new formats. WebP has broad tooling support and decodes quickly; AVIF can produce smaller files but takes longer to encode, which matters if you convert at build time. The trade-offs are laid out in AVIF vs WebP vs JPEG for the web, and what is WebP is a good primer for the team.

To convert existing assets, convert images between formats for single files, use the bulk image converter for a directory, or go straight to the targeted pages to convert image to WebP and convert images to AVIF. Keep your originals (PNG masters, camera files) in version control or storage separate from the generated assets.

Serve the formats with <picture> so the browser picks the first source it supports:

<picture>
  <source srcset="hero-960.avif 960w, hero-1600.avif 1600w" type="image/avif" sizes="100vw">
  <source srcset="hero-960.webp 960w, hero-1600.webp 1600w" type="image/webp" sizes="100vw">
  <img src="hero-960.jpg" srcset="hero-960.jpg 960w, hero-1600.jpg 1600w" sizes="100vw"
       width="1600" height="900" alt="Describe the image here">
</picture>

Keep the sizes value honest. If the image only fills half the viewport, say so (50vw), or the browser will download a larger file than needed.

Step 3: Compress against a budget

Set a byte budget per image class and treat it like a test. Reasonable starting points differ by site, but many teams aim for content images in the low hundreds of kilobytes and hero images somewhat higher, then tighten as they measure. Quality settings are not portable between encoders, so judge by eye and by bytes, not by a number.

For batches of photos and graphics, run files through the image optimizer and compare before and after at 100 percent zoom, with particular attention to text, gradients and skin tones. The reasoning behind the settings is in compress images for a faster website. Do not rely on lossless claims; verify the visual result for each content type.

Two rules save a lot of trouble: compress from the original, never from an already-compressed derivative, and strip nothing you legally or editorially need (such as credits) without noticing.

Step 4: Dimensions, lazy loading and the LCP image

Three attributes do most of the work for Core Web Vitals.

Width and height. Include them on every <img>. Modern browsers use them to compute an aspect ratio and reserve space before the file loads, which prevents layout shift. With fluid CSS (max-width: 100%; height: auto;) the ratio is preserved.

Lazy loading. Add loading="lazy" to images below the fold so they load on demand. Optionally add decoding="async".

The LCP image. On most pages the largest above-the-fold image is the LCP element. Do not lazy-load it. Give it a hint to load early, either fetchpriority="high" on the <img> or a preload link when it is referenced from CSS or discovered late:

<link rel="preload" as="image" href="hero-1600.avif" type="image/avif" fetchpriority="high">

Use preload sparingly. Preloading several images makes them compete and can delay the one that matters. The full picture of how these signals interact is in image optimization for Core Web Vitals: fix LCP and CLS image problems there first, then return to byte savings.

If you use a framework image component, check what it already does (size generation, lazy loading, format negotiation) so you do not duplicate or fight it, and confirm the rendered HTML includes the attributes above.

Step 5: Batch processing and one-off sites

Not every project has a pipeline. For a small marketing site, a portfolio or a quick content update, a manual batch is perfectly reasonable:

  1. Export masters from design tools at the largest needed size.
  2. Run them through the bulk image resizer for each target width.
  3. Run the results through the bulk image converter to produce WebP or AVIF.
  4. Pass the final set through the image optimizer if you need to hit a smaller budget.
  5. Commit the output with descriptive filenames such as team-photo-960.webp.

Because the tools run in the browser, nothing leaves your machine, which helps with client work under NDA and with unreleased product imagery. The bulk resizer and bulk converter give you ZIP downloads.

Larger or fast-changing projects should move this into the build: a script or image service that generates widths and formats from masters. The decisions stay the same, only the executor changes.

Step 6: Verify

  • Lab tests such as Lighthouse show LCP element, image weight and missing dimensions.
  • Field data (real-user measurement) shows what visitors actually experience, which matters more than a single lab run.
  • Network panel: check that the right format and width are downloaded on a phone-sized viewport, and that images below the fold are not fetched on load.
  • Visual review: compare against the original at full zoom for banding, halos and blocky text.

Product catalogs deserve special care because they combine volume, consistency and quality demands; see product photo sizes for online stores.

Developer checklist

  • Sizes planned per breakpoint, with no upscaling.
  • AVIF or WebP served with a JPEG or PNG fallback.
  • Per-class byte budgets, enforced in review.
  • width and height on every image.
  • loading="lazy" below the fold; never on the LCP image.
  • LCP image prioritized and verified in field data.
  • Originals stored separately from generated assets.

Frequently asked questions

Should I use WebP or AVIF?

AVIF can be smaller but takes longer to encode, while WebP has broader tooling support. A common approach is to serve AVIF or WebP with a JPEG fallback using the picture element.

How do I avoid layout shift from images?

Set width and height attributes (or an aspect ratio) so the browser reserves space before the image loads.

Which image should I preload?

Usually the largest above-the-fold image, which is often the Largest Contentful Paint element. Do not lazy-load that one.

Can I prepare images in bulk without a build step?

Yes. The bulk resizer and bulk converter work in the browser and give you a ZIP, which is handy for one-off batches or small sites.

Related guides

Ready to start? Run your largest images through the image optimizer and see what your budget looks like.

All image guides