How Browsers Handle Images: From Download to Display

Browsers handle website images in four main steps. They discover the image, choose a file to download, decode that file into pixels, and draw it on the page. A delay can occur at any step. If a large banner appears late, check when the browser found it and which file it chose before changing the compression level.

For a faster-loading page, start by choosing an image format. If your upload has a maximum size, see how to meet a file-size limit.

What happens between the HTML and the screen?

StageWhat the browser doesWhat to check when it is slow
DiscoveryFinds the image URL in HTML, CSS, or content added laterCheck when the request starts and what triggered it.
Selection and downloadChooses a candidate and requests the file or loads a local copyCheck the actual URL, transferred bytes, and timing.
DecodingReads the image format and produces pixels it can displayCheck whether the source has far more pixels than the display needs.
Layout and paintingReserves space and draws the pixels when the page can display themCheck image dimensions, layout shifts, and other work in the rendering trace.

These steps can overlap. For example, the browser can discover an image while it continues to read the HTML. It can also show parts of some images before every byte arrives. However, a fast download alone cannot guarantee the image appears early. The page must also make room for it and reach the point where the browser can paint it.

Discovery: How the browser finds the image URL

When a page includes an image directly in its HTML, the browser can often start its request while it reads other markup. That gives a key visual, such as a product photo, time to load in the background. By comparison, a CSS background image usually becomes discoverable once the browser has the relevant style information. An image inserted by JavaScript may also wait for the script and any data it needs.

For example, suppose your homepage displays a single hero photo, but the URL lives in a slider configuration. If the slider script runs late, the image request can also start late. Therefore, check whether the first slide can appear as an image in the initial HTML. You can still add interaction for the rest of the slider after the main photo becomes available.

Selection: Which file does the browser download?

One image can have several available widths. An image element with a width-based source set lists candidate URLs and their pixel widths. In addition, a sizes attribute describes how wide the image will appear in the layout. The browser can use those hints and the device pixel ratio when selecting a resource. A picture element can instead offer different crops or formats under specified conditions.

For instance, a phone may show a product card at 320 CSS pixels wide. On a device with a pixel ratio of two, a file around 640 pixels wide can make sense. However, this calculation gives you a way to plan candidates, not a promise about the exact choice on every device. Check the request the browser actually made. MDN’s responsive images guide explains the two approaches and includes markup examples.

When you need to create candidates, start from the original and use the Pic Resize Image resizer to export useful widths. Also, keep the same aspect ratio across alternate resolutions of the same crop. If a mobile layout needs a closer crop, prepare a separate version with Crop Image Online Free and choose that crop through the layout’s image markup.

Downloading and decoding are different jobs

The browser transfers the encoded file over the network if it cannot reuse an appropriate cached copy. A 180 KB image tells you something about the transfer, but it does not tell you how many pixels the browser must handle. After the bytes arrive, the browser decodes that data into image pixels it can draw.

As a simple illustration, an uncompressed 3000 × 2000 image with four bytes per pixel would take about 24 million bytes for one pixel buffer. Actual memory use varies with the browser and rendering path. Still, the example explains why a highly compressed but oversized photo can need substantial memory. First match the source dimensions to the layout, then reduce the file size where the image still looks clear.

Rendering: Give the image a space to fill

Set width and height attributes that describe the image’s aspect ratio, and let CSS scale it for the layout. The browser can then reserve the right shape before the file appears. Otherwise, the page may expand after the image arrives and push a headline, button, or paragraph out of place.

For example, a 1200 × 800 photograph has a 3:2 ratio. If a page displays it at 600 pixels wide, the browser can reserve roughly 400 pixels of height when the layout keeps that ratio. If the art direction changes on smaller screens, make sure the mobile slot also has the right dimensions or a matching CSS aspect ratio.

A five-minute image loading check

  1. Open the Network panel. Reload the page and filter requests to images. For a cold-load comparison, disable the cache during the test and use the same conditions for each run.
  2. Find the main visible photo. Check the URL and the request start time. Next, look at the initiator to see whether HTML, CSS, or JavaScript led to the request.
  3. Inspect the downloaded candidate. Compare its intrinsic pixel width with the rendered slot and device pixel ratio. If the browser downloads a much larger file than the slot needs, inspect the responsive image hints.
  4. Review the loading strategy. If the first visible hero uses lazy loading, check whether deferral is delaying it. Save lazy loading for lower images, such as product cards farther down the page.
  5. Check the rendering timeline. If the main image downloads early but still appears late, record a performance trace. Look for render delays and layout shifts before spending more time changing the image format.

Keep a simple before-and-after record of the first request time, bytes transferred, and display size. Then change one thing and test again. This makes it easier to see whether a smaller file, earlier discovery, or a better candidate made the difference. web.dev’s image performance guide gives more examples of testing browser loading behaviour.

Frequently asked questions

1. Does a smaller JPEG always appear sooner?

No. Fewer bytes can reduce download time, but discovery, download priority, decoding, and rendering can also affect when it appears.

2. Does CSS width make the downloaded file smaller?

No. CSS changes the display dimensions. To send fewer bytes, supply a smaller file or offer responsive candidates and accurate size hints.

3. Can I lazy-load the main homepage image?

It is normally better to let an immediately visible main image load without deferral. Use lazy loading for images farther down the page, and test on a mobile connection.

4. Why does my second visit look much faster?

The browser may reuse copies from its cache. A user arriving for the first time can face a different loading experience, so check both cached and uncached visits.

5. Is WebP always quicker for browsers?

How quickly an image appears depends on the actual bytes, pixel count, request timing, and decoding. Compare real files and timings on the same page before choosing.

6. Why does my layout jump when a photo loads?

The page may not have reserved the right space. Provide width and height or an appropriate CSS aspect ratio so nearby content stays in place when the image appears.

7. Which image should I optimise first?

Start with the image visitors need to see first, especially if testing identifies it as the Largest Contentful Paint element. Check when its request begins and whether the browser selects a sensible file size.

Fix the slowest step first

If the request starts late, help the browser discover the image sooner. If it starts early but transfers too many bytes, choose better dimensions or compression. Finally, when the file arrives quickly and still appears late, look at rendering. Each test points to a different fix.

About the author

Picture of Pic Resize Image

Pic Resize Image

Pic Resize Image publishes practical guides on resizing, cropping, and compressing images for websites, email, and online forms.