Ch. 20 · Optimizing Web Images and Animations

한국어日本語
6 min

Checking Browser Support: State the Date, Don't Assert

Support status keeps changing, so don't trust a table in an article; learn how to check. There are public resources like caniuse, the picture fallback structure, and ways to detect support in code.

This lesson deliberately does not include a table of 'which browser supports which format'. The reference date this was written is November 11, 2026, and especially for JPEG XL, sources disagree on when support arrived and whether it's on by default. When we checked through a web search, the timing for Chrome and Firefox differed from one article to the next, and while every source agreed Safari supports it from version 17, that too needs to be checked yourself. So instead of asserting, we'll show you how to check.

Method 1: Look at public compatibility data

  • On Can I use (caniuse.com), searching by format name such as avif, webp, or jpegxl gives a table by browser and version. Look at the page's last-updated date too.
  • MDN's guide to image file types lists browser compatibility for each format.
  • 'Partial support' or 'behind a flag' in a table may mean it doesn't work with default settings, so read it based on the default settings most users have.

Method 2: Use a structure that doesn't require knowing support

The safest approach is to let the browser choose for itself rather than memorize the support status. The <picture> in the next lesson is exactly that structure. The browser reads the <source> elements from the top, picks the first one whose type it can interpret, and falls back to the final <img> if there is none. If you put the new format on top and JPEG in the bottom <img>, you don't have to detect support yourself.

Method 3: If you have to detect it in code

In places where you can't use <picture>, such as CSS background images, you can detect support with a page script. Loading a very small sample image into an Image object and checking whether it succeeds has been used for a long time. This site's codec support checker is for detecting video and audio codecs and does not check image formats, so for images, check with the public resources above or with a test of your own.

A conceptual example of checking support inside the browser, without sending anything to a server
<script>
  // The sample in the data URL must be a real 1×1 image made in that format
  function canDecode(dataUrl) {
    return new Promise((resolve) => {
      const img = new Image();
      img.onload = () => resolve(img.width > 0);
      img.onerror = () => resolve(false);
      img.src = dataUrl;
    });
  }
</script>
'It opens' is not the same as 'every feature works'

Even for the same format, support for extras such as animation, alpha, and 10-bit/HDR can differ by browser. A single photo displaying doesn't mean the feature you want to use works, so make a test file using the feature you intend to use and open it in several browsers. It's the same as checking 10-bit support separately for video (Bit depth in practice).

Summary

Leave support status to data and structure, not to an article. When you check, write down the date, read it against users' default settings, and always keep a fallback.

Feature detectionFeature detection

Instead of guessing from the browser name or version, you test whether the feature actually works.

Can I useCan I use

A public site that collects browser support status for web technologies. Check its last-updated date too.

Check yourself

What is the safest attitude toward browser support status?

Check yourself

What can you learn with this site's codec support checker?