Shopify Product Page Optimization: Images, Videos, Product Media and Loading Priorities

Faster product media without compromising how the product looks — image_url, image_tag, gallery loading order and click-to-play video.

In short

On most Shopify stores the product page is where the traffic lands and where the media is heaviest. Four things go wrong, and all four are fixable without making products look worse:

  1. The main image is requested at the wrong size, so a phone downloads a desktop image.
  2. The whole gallery loads up front instead of the one image anyone can see.
  3. Video loads before anyone presses play.
  4. Images have no dimensions, so the page jumps as they arrive.

The constraint that makes this different from general image advice: product presentation is what sells the product. You cannot compress your way to a fast page if the result makes the fabric look wrong. So the savings have to come from dimensions, format and loading order — not from quality.

What Shopify does for you here

Worth knowing before you optimise something that is already handled.

Shopify's image CDN resizes and converts on request. You ask for a width, it serves that width, in a modern format where the browser supports one. You do not control the encoder settings, and you do not need to pre-generate sizes.

The general rules behind this — dimensions before format, format before compression — are in website image optimization. What it means on Shopify in practice: uploading a large original is correct. Upload the highest quality you have, then request appropriate sizes in your theme. The mistake is not the upload — it is requesting the original in your template.

Getting the main image right

The first gallery image is almost always your LCP element. It needs four things: the right sizes, an accurate sizes attribute, eager loading, and high priority.

{%- comment -%}
  The main product image. image_tag emits width and height for you, which prevents layout shift.
{%- endcomment -%}
{%- assign featured = product.selected_or_first_available_variant.featured_media
      | default: product.featured_media -%}

{{ featured
   | image_url: width: 1600
   | image_tag:
       loading: 'eager',
       fetchpriority: 'high',
       sizes: '(min-width: 990px) 50vw, 100vw',
       widths: '400, 600, 800, 1000, 1200, 1600',
       alt: featured.alt | default: product.title,
       class: 'product-media__image' }}

Three details that matter more than they look:

image_url needs a width. Without one you get the original, which may be several thousand pixels wide.

sizes is the part everyone gets wrong. It tells the browser how wide the image will be before the CSS has loaded, so it can pick from widths. If it says 100vw when the image actually occupies half the screen on desktop, the browser downloads roughly twice the pixels it needs. Describe your real layout, breakpoint by breakpoint.

loading: 'eager' and fetchpriority: 'high' — one image per page gets this. Marking several high priority means marking none.

A product page with twelve images should download one. The other eleven are not visible and most visitors will never scroll the gallery.

{%- for media in product.media -%}
  {%- if forloop.first -%}
    {{ media | image_url: width: 1600 | image_tag:
         loading: 'eager', fetchpriority: 'high',
         sizes: '(min-width: 990px) 50vw, 100vw',
         widths: '400, 600, 800, 1000, 1200, 1600',
         alt: media.alt | default: product.title }}
  {%- else -%}
    {{ media | image_url: width: 1200 | image_tag:
         loading: 'lazy',
         sizes: '(min-width: 990px) 50vw, 100vw',
         widths: '400, 600, 800, 1000, 1200',
         alt: media.alt | default: product.title }}
  {%- endif -%}
{%- endfor -%}

Thumbnails are a separate request

A thumbnail displayed at 80 pixels should be requested at about 160 — not at 1200, and not the same URL as the main image.

{{ media | image_url: width: 160 | image_tag:
     loading: 'lazy', widths: '80, 160, 240',
     sizes: '80px', alt: '' }}

Requesting the full-size image for thumbnails is a common theme bug. Twelve thumbnails at full size is twelve unnecessary large downloads.

Video and 3D models

Product video is the heaviest thing on a product page and the least likely to be watched.

Never autoplay video on mobile. It downloads a large file for every visitor, and most of them did not want it.

Use a poster image and load the player on interaction. For hosted Shopify video, video_tag accepts a poster and you can leave autoplay off:

{{ media | video_tag:
     image_size: '1200x',
     controls: true,
     autoplay: false,
     loop: false,
     preload: 'none' }}

preload: 'none' is the important part — it tells the browser not to fetch the video until someone presses play.

For external video (YouTube, Vimeo), the embed loads a substantial player. Show the poster image as a plain <img> with a play button, and insert the iframe on click. A visitor who does not press play downloads an image instead of a player.

3D models load a viewer library. Treat them like video: poster first, load on interaction.

Reviews, recommendations and badges

These are app-driven and are covered properly in the apps and scripts guide. Two product-page-specific points:

Reserve space for anything that loads late. A review widget that starts at zero height and expands pushes everything below it down, which damages CLS. Give the container a min-height matching its usual filled size.

Recommendations can load on scroll. Shopify's product recommendations endpoint can be requested when the section approaches the viewport rather than on page load. The section is below the fold; the request does not need to compete with your main image.

Preventing layout shift

image_tag emits width and height, which is why it is worth using rather than hand-writing <img>. If your theme has hand-written tags, that is likely your CLS problem.

Where the markup is not yours to change, CSS achieves the same reservation:

.product-media__image { aspect-ratio: 1 / 1; width: 100%; height: auto; }

Also reserve space for the variant picker if it changes size when a variant is selected, and for any badge or stock message that appears after load.

You can see the difference a single pair of attributes makes in our performance lab — two identical pages, one with reserved space and one without.

Working out the real displayed size

The whole exercise depends on knowing how wide your images actually render. Guessing leads to sizes values that are wrong in one direction or the other.

  1. Open a product page, set the viewport to a phone width.
  2. In the Elements panel, hover the main image. Chrome shows the intrinsic size and the rendered size.
  3. Repeat at tablet and desktop widths.
  4. Multiply the rendered width by the device pixel ratio you want to support — roughly 2 for modern phones.

What you should see: the intrinsic size close to the rendered size times the pixel ratio. If intrinsic is far larger, you are paying for pixels nobody sees.

Common mistakes

Compressing images to fix a size problem. If the dimensions are wrong, compression is treating the symptom.

A sizes value that does not match the layout. The most common cause of a phone downloading a desktop image despite correct srcset.

Lazy-loading the first gallery image. Directly delays LCP.

Marking several images high priority. They compete, and the real LCP image arrives later.

Requesting the original image. image_url without a width.

Autoplaying video on mobile.

Full-size thumbnails.

Degrading quality to hit a score. If the product looks worse, you have made the page worse. Take the saving from dimensions and loading order.

Testing on desktop only. The LCP element and the constraints both differ on mobile.

Verification

  1. Identify the LCP element on a phone viewport and confirm it is the main product image — then confirm its request starts almost immediately after the HTML arrives.
  2. Check the transferred size of the main image in the Network panel, and confirm intrinsic and rendered sizes are now close in the Elements panel.
  3. Confirm the gallery is deferred: reload without scrolling and check only the first image was requested.
  4. Confirm video was not fetched until you pressed play.
  5. Look at the product. Full size, on a high-density screen, against the original. If presentation suffered, undo it and take the saving elsewhere.
  6. Check CLS with Layout Shift Regions on, including when selecting a variant.
  7. Test on a real mid-range phone, not just emulation.
  8. Complete a real test order from this page.
  9. Then watch field data for four weeks.

When it still does not improve

  • LCP has not moved → confirm which element is actually the LCP element on mobile. If it is a banner above the gallery, or a text block, that is what to work on.
  • The image is small but LCP is still late → the cost is discovery or rendering, not download. Check it is in the initial HTML with View Source, and that no stylesheet or script is blocking the paint.
  • Variant switching is slow → that is responsiveness, not media. The variant picker is running JavaScript on the main thread.
  • The gallery still downloads everything → a gallery or slider script may be loading all images regardless of the loading attribute. Check what the script does.
  • CLS is still poor → something else arrives late. Reviews widgets and stock badges are the usual candidates.

Keeping product pages fast

Product pages decay faster than anything else on a store, because new products are added constantly by people who are not thinking about file sizes.

Three habits: set an upload guideline whoever adds products knows about, keep image_url widths and sizes values correct in the theme so every new product inherits them, and spot-check a newly added product every month to confirm it behaves like the rest.

Frequently asked questions

What size should Shopify product images be?

Upload the highest quality original you have — Shopify’s image CDN resizes and converts on request, so a large upload is correct. The mistake is in the theme: requesting the original instead of asking for a width with image_url. Work out the real rendered width at each breakpoint and roughly double it for high-density screens.

Why is my Shopify product page slow even though images are compressed?

Compression is rarely the problem on Shopify, because the CDN already handles format and encoding. The usual causes are requesting the wrong dimensions, loading the whole gallery up front, full-size thumbnails, and video that fetches before anyone presses play.

Should I lazy-load Shopify product images?

The gallery, yes. The first image, never — it is almost always your LCP element, and lazy-loading it directly delays the metric Google measures. Make the first image eager with fetchpriority high, and lazy-load everything after it.

How do I stop Shopify product video slowing the page?

Do not autoplay on mobile, and set preload to none so the browser does not fetch the file until someone presses play. For YouTube or Vimeo embeds, show a poster image with a play button and insert the iframe on click.

What does the sizes attribute do, and why does it matter?

It tells the browser how wide the image will be before the CSS has loaded, so it can choose the right file from your widths. If it says 100vw when the image actually occupies half the screen on desktop, the browser downloads roughly twice the pixels it needs. It is the most commonly wrong part of responsive images.

Will optimising images make my products look worse?

It should not. Product presentation is what sells the product, so take the saving from dimensions, format and loading order rather than from quality. If the product looks worse at full size on a high-density screen, undo it and find the saving elsewhere.

References