You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Image Preview for HTML Images] Do better than blurhash #1406
Blurhash is cute and nothing else. It's close to useless even compared to CSS features we may soon get. It seems like sites are moving away from it for good reason.
For example, I was sent an X link while I was on a train, and this is what I saw:
This was pretty good because:
I knew I was looking at a preview
I know there are two people in the image, and given the context I have a reasonable idea who they are.
I know it's in the format of a particular meme
Here's a blurhash of the same image:
Other than looking like a preview, the blurhash tells me nothing. The only good thing about it is that it's 148 bytes.
This is what AVIF can do in 1kb:
This is even better than the example X provided, and I'd guess it was done in fewer bytes.
I'm not saying that AVIF is the solution. For starters, a 1x1 AVIF is 300 bytes, so there's a lot of overhead in the format. What I'm saying is - look at what's possible in 1kb bytes with a format that isn't even optimised for this usecase. So, if we actually tried, how small could we get something that's actually useful to users? If we could get a result that's this functionally useful down to 300 bytes, I'd say that's way more compelling than a blurhash, which although is smaller, offers the user very little other than a cute gradient.
Reacted by Bramus, Terence Eden, Michaël Vanderheyden, Felix Icaza, Oliver Williams, Vladimir Agafonov, Aleksandr Hovhannisyan, Matías Juarez, Iacopo Moles and Paweł Grzybek
This isn't as good as the AVIF, but it's way better than the blurhash. Given it's 8x8 control points, that's… 192 bytes (without compression)? And I'm sure we can do better.
https://www.keithcirkel.co.uk/avash/ here's a library for producing AVIF frames as a base88 string that can be popped into an image attribute, akin to Blurhash. You can upload an image, click "match blurhash length" and frequently get a more recognisable image out of the other end. Admittedly this does need a 2kb support library; roughly on par with what you'd need for BlurHash.
Reacted by Jake Archibald, Michaël Vanderheyden and Paweł Grzybek
Yes, the 287 byte preview is 10x more bytes, but it actually offers something of value - you can tell meaningful things about the image.
If you're prepared to spend 668 bytes, you can get something even better:
Taking the X example:
Here's a 298 byte preview:
Compare to a thumbhash of 21 bytes:
And if you're willing to spend 678 bytes, you can do even better:
I'm going to keep reiterating this because folks keep missing it: I'm not saying that AVIF is the answer. I'm saying that there's clearly evidence that there's scope to add a few more bytes and produce something actually useful. I'm pretty sure AVIF is not optimised for this use-case. Another format could be.
I think you've made your point very clearly Jake Archibald (@jakearchibald), and I fully agree with the fact that if you're willing to spend around 10x more bytes, you get a much better preview that actually ressembles the final image.
I also fully expect that many sites will prefer this over an unrecognizable blur.
However, I don't think this claim is supported by objective user data: that a recognizable preview always produces better user outcomes, in all cases.
Is the extra detail always worth the cost?
Does something as abstract as blurhash really offer no user value, ever?
Wouldn't an image-heavy site where images are decorative or secondary, and where recognition is not part of the user’s task, benefit from inlined abstract previews? Perhaps to preserve color balance and visual rhythm, and avoid a wall of gray rectangles?
Does something as abstract as blurhash really offer no user value, ever?
I'd be good to reverse the burden of proof on this. Can someone detail what value it offers, compared to things the platform already supports (like a single color, or a gradient)?
And given the increasing popularity of wide-gamut, what's the reason why it isn't needed for these abstract previews (given it'll cause a color jump when moving to the real image)?
Wouldn't an image-heavy site where images are decorative or secondary, and where recognition is not part of the user’s task, benefit from inlined abstract previews?
I'd like to know more about that situation.
In my experience, image-heavy sites are where recognition matters most. Many images makes it more likely that it'll be slow to load, and recognition means I may be able to skip that loading and click through.
I'd be good to reverse the burden of proof on this. Can someone detail what value [blurhash] offers, compared to things the platform already supports (like a single color, or a gradient).
Oh the question isn't what blurhash offers. It's what very blurry/unrecognizable previews offer.
I'm not arguing for blurhash. I'm arguing for a platform-provided way to do what it does. If that's gradients, great!
Is the extra detail always worth the cost? Does something as abstract as blurhash really offer no user value, ever? Wouldn't an image-heavy site where images are decorative or secondary, and where recognition is not part of the user’s task, benefit from inlined abstract previews? Perhaps to preserve color balance and visual rhythm, and avoid a wall of gray rectangles?
I'd love to hear from others on this.
Personally, I think both can be useful, however I would only rely on blurhash for 2 reasons:
The image is purely decorative and not prominent (e.g. some background image). I would'd prefer a low res image for all other use cases I can think of even prominent decorative images.
If the use explicitly wants to save bandwidth (prefers-reduced-data)
Otherwise, from a developer point of view, if I'm spending effort to generate a preview, I'd always go with the visually better option, even if that means more bytes.
I think the added benefit of blurhash is not enough to spend the extra effort in many cases.
I'm not arguing for blurhash. I'm arguing for a platform-provided way to do what it does. If that's gradients, great!
Yeah, I'm much less concerned if this is just using things that are already there (like gradients, and soon, patch gradients). Although, I'd still encourage folks to think carefully about the user value of an illegible preview vs a legible one.
Personally, my questions are less along the lines of what preview to use and more along the lines of:
Is there any UX research on any of the preview options (from skeleton screens, to gradients, to blur hash, to low-res preview, to high-res preview)? I take Patrick Brosset (@captainbrosset) 's point that they are popular in frameworks, but that doesn't mean they are actually useful! That's not to say popularity isn't a useful signal, but I'd much prefer if we had actual UX research to back up the user benefit.
Why is progressiveness not the answer here instead of a separate image? That way the preview bytes are not wasted when the full image comes in? Though the value of progressiveness has never been proven either as far as I know...
IMHO placeholder images work best when inlined so they are available immediately rather than needing a download. That avoids the double download, and means the browser can get on with prioritising the actual image! I'd much rather NOT have a preview image at all if the main image is fast enough. But that does limit options to a solid colour/gradient or a very blurry blurhash.
I also don't fully understand how this can be baked into the platform as a separate resource? I presume the proposal is not to download the main image, apply a blurhash, and then show that as that requires the image. And if it's only the first few bytes when again, why doesn't progressive images provide that instead of a separate resource URL in previewsrc that seems very much part of the current proposal?
All of these questions to me mean issue #1400 needs to be addressed first to explain why this will succeed where lowsrc didn't, before we can get into what format previewsrc should use (and how the web platform can provide that).
Reacted by Michaël Vanderheyden, Terence Eden, Felix Icaza and Noam Rosenthal
fwiw I agree that, unless the previewsrc is inlined, I don't see the benefit of this vs a progressive image. Except for handling lazy loading of each part differently, which the explainer currently forbids #1404.
I thought about patterns where previewsrc contains the start of the src, so the browser makes a range request for the src and caches the combined resource. But that seems very complicated, and raises a lot of security questions.
Another pattern would be to use an attribute to hint at how much of the image should be downloaded to get a preview. That would be safer.
Does something as abstract as blurhash really offer no user value, ever?
I'd love to hear from others on this.
I think blurhash techniques can offer some value, purely on the basis that it offers something instead of nothing. The question is how much value is that, and what is the cost of it. blurhash effectively requires implementing Yet Another Decoder into the platform, and requires users interact with Yet Another Encoder. In my opinion leveraging existing platform features (or even theoretical ones) can potentially get us higher reward with less work. I am quite sure by the time mesh gradients are implemented someone will have a blurhash style technique just using these; is that enough?
In my opinion leveraging existing platform features (or even theoretical ones) can potentially get us higher reward with less work. I am quite sure by the time mesh gradients are implemented someone will have a blurhash style technique just using these; is that enough?
I think blurhash techniques can offer some value, purely on the basis that it offers something instead of nothing. The question is how much value is that, and what is the cost of it. blurhash effectively requires implementing Yet Another Decoder into the platform, and requires users interact with Yet Another Encoder. In my opinion leveraging existing platform features (or even theoretical ones) can potentially get us higher reward with less work. I am quite sure by the time mesh gradients are implemented someone will have a blurhash style technique just using these; is that enough?
I agree with this.
I've been using LQIP-based techniques for a few years, and it’s really great to see a native proposal for their implementation. I agree that BlurHash is a useful starting point, but there are several approaches to generating image previews, beyond those already mentioned here, and the differences between them can be quite significant.
ThumbHash was specifically designed as an alternative to BlurHash, as it provides more information and allows for encoding more detail while taking up virtually the same amount of space, all while preserving aspects such as aspect ratio, greater color fidelity, and the alpha channel. There are also very different approaches, such as SQIP which uses SVG primitives, Gradify which is based on CSS linear gradients, or CSS-only LQIP by Lean Rada based on radial gradients.
I find these methods interesting precisely because they involve different trade-offs; while some approaches are less robust in terms of the information they provide while the high-resolution image loads, I believe that the best preview may depend largely on the image and the context. Therefore, I would consider BlurHash simply as one more option within a range of techniques already explored by developers.
There are also very different approaches, such as ... Gradify which is based on CSS linear gradients, or CSS-only LQIP by Lean Rada based on radial gradients.
Thanks for the suggestions to use gradients and other CSS-generated images as previews.
The current proposal does not support these values directly. previewsrc accepts a URL, while gradients and similar values use the CSS <image> syntax.
Authors can use a gradient as the background of an <img>, or create an SVG or raster image with a similar appearance and reference it from previewsrc. However, these are workarounds and are not the same as allowing a CSS image to be used directly as the preview.
Supporting CSS images directly would require a CSS property or another CSS integration. We would also need to define when the CSS preview is replaced and how it interacts with the image and transitions.
I think this is an important limitation of the proposed API, and it is not clear enough in the current explainer. I will update the explainer to mention it explicitly and describe CSS-image support as a possible separate or companion feature.
Authors can use a gradient as the background of an <img>, or create an SVG or raster image with a similar appearance and reference it from previewsrc. However, these are workarounds and are not the same as allowing a CSS image to be used directly as the preview.
Setting the background image as preview might lead to unwanted results once the image is loaded, especially if the image contains transparent parts. For this to work, we'd need img state pseudo-classes to remove/hide the background once the image is properly loaded
This is a different approach. #1405 is adding new pseudo-class to explicitly handle a dedicated preview source.
My suggestion above was rather about using existing feature like background image to display the preview and use state pseudo-classes to hide it when the image is loaded.
This solution would have the advantage that it doesn't require new attributes but probably has disadvantage to the proposed solution here that you know better than me
#1405 (comment) - this covers why putting a background on the image isn't enough.
Additionally, imagine the image is a WebP with transparency. These render top-to-bottom. What would you do whilst 10% of the main image has rendered? It would either render on top of your background image, or you'd hide the background image, meaning you've switched from a full preview to 10% of the image.
Activity
jakearchibald commentedon Sep 22, 2026
Taking the example from Patrick Brosset (@captainbrosset)'s post:
Here's the blurhash:
Here's a 1 kB AVIF:
And here's the final image:
Which preview is more useful to a user?
https://tryhoverify.com/tools/image-to-mesh-gradient/ lets you generate mesh gradients from an image, and here's how it does:
This isn't as good as the AVIF, but it's way better than the blurhash. Given it's 8x8 control points, that's… 192 bytes (without compression)? And I'm sure we can do better.
keithamus commentedon Sep 22, 2026
https://www.keithcirkel.co.uk/avash/ here's a library for producing AVIF frames as a base88 string that can be popped into an image attribute, akin to Blurhash. You can upload an image, click "match blurhash length" and frequently get a more recognisable image out of the other end. Admittedly this does need a 2kb support library; roughly on par with what you'd need for BlurHash.
jakearchibald commentedon Sep 23, 2026
Additionally, adding a 'preview' image format to the web that's limited to sRGB seems incredibly short sighted.
jakearchibald commentedon Sep 23, 2026
Similar to Keith Cirkel (@keithamus), I slopped around a bit with AVIF. It seems like there are smoothing filters in there that can help a lot.
Taking Patrick Brosset (@captainbrosset)'s image:
Here's a 287 byte preview:
Compare to a thumbhash of 21 bytes:
Yes, the 287 byte preview is 10x more bytes, but it actually offers something of value - you can tell meaningful things about the image.
If you're prepared to spend 668 bytes, you can get something even better:
Taking the X example:
Here's a 298 byte preview:
Compare to a thumbhash of 21 bytes:
And if you're willing to spend 678 bytes, you can do even better:
I'm going to keep reiterating this because folks keep missing it: I'm not saying that AVIF is the answer. I'm saying that there's clearly evidence that there's scope to add a few more bytes and produce something actually useful. I'm pretty sure AVIF is not optimised for this use-case. Another format could be.
jakearchibald commentedon Sep 23, 2026
Just to keep hammering the point:
What is this?
It's 21 bytes… but it's just a blob. Other than knowing it's not-loaded, it tells me nothing.
But if you're willing to spend 593 bytes:
Now you can tell what it is. You can decide whether it's worth waiting for it to fully load or not.
And here's the full thing:
Let's do the better thing, but even better.
captainbrosset commentedon Sep 23, 2026
I think you've made your point very clearly Jake Archibald (@jakearchibald), and I fully agree with the fact that if you're willing to spend around 10x more bytes, you get a much better preview that actually ressembles the final image.
I also fully expect that many sites will prefer this over an unrecognizable blur.
However, I don't think this claim is supported by objective user data: that a recognizable preview always produces better user outcomes, in all cases.
Is the extra detail always worth the cost?
Does something as abstract as blurhash really offer no user value, ever?
Wouldn't an image-heavy site where images are decorative or secondary, and where recognition is not part of the user’s task, benefit from inlined abstract previews? Perhaps to preserve color balance and visual rhythm, and avoid a wall of gray rectangles?
I'd love to hear from others on this.
jakearchibald commentedon Sep 23, 2026
I'd be good to reverse the burden of proof on this. Can someone detail what value it offers, compared to things the platform already supports (like a single color, or a gradient)?
And given the increasing popularity of wide-gamut, what's the reason why it isn't needed for these abstract previews (given it'll cause a color jump when moving to the real image)?
I'd like to know more about that situation.
In my experience, image-heavy sites are where recognition matters most. Many images makes it more likely that it'll be slow to load, and recognition means I may be able to skip that loading and click through.
captainbrosset commentedon Sep 23, 2026
Oh the question isn't what blurhash offers. It's what very blurry/unrecognizable previews offer.
I'm not arguing for blurhash. I'm arguing for a platform-provided way to do what it does. If that's gradients, great!
Th3S4mur41 commentedon Sep 23, 2026
Personally, I think both can be useful, however I would only rely on blurhash for 2 reasons:
prefers-reduced-data)Otherwise, from a developer point of view, if I'm spending effort to generate a preview, I'd always go with the visually better option, even if that means more bytes.
I think the added benefit of blurhash is not enough to spend the extra effort in many cases.
jakearchibald commentedon Sep 23, 2026
Yeah, I'm much less concerned if this is just using things that are already there (like gradients, and soon, patch gradients). Although, I'd still encourage folks to think carefully about the user value of an illegible preview vs a legible one.
tunetheweb commentedon Sep 23, 2026
Personally, my questions are less along the lines of what preview to use and more along the lines of:
I also don't fully understand how this can be baked into the platform as a separate resource? I presume the proposal is not to download the main image, apply a blurhash, and then show that as that requires the image. And if it's only the first few bytes when again, why doesn't progressive images provide that instead of a separate resource URL in
previewsrcthat seems very much part of the current proposal?All of these questions to me mean issue #1400 needs to be addressed first to explain why this will succeed where
lowsrcdidn't, before we can get into what formatpreviewsrcshould use (and how the web platform can provide that).jakearchibald commentedon Sep 23, 2026
fwiw I agree that, unless the
previewsrcis inlined, I don't see the benefit of this vs a progressive image. Except for handling lazy loading of each part differently, which the explainer currently forbids #1404.I thought about patterns where
previewsrccontains the start of thesrc, so the browser makes a range request for thesrcand caches the combined resource. But that seems very complicated, and raises a lot of security questions.Another pattern would be to use an attribute to hint at how much of the image should be downloaded to get a preview. That would be safer.
keithamus commentedon Sep 23, 2026
I think blurhash techniques can offer some value, purely on the basis that it offers something instead of nothing. The question is how much value is that, and what is the cost of it. blurhash effectively requires implementing Yet Another Decoder into the platform, and requires users interact with Yet Another Encoder. In my opinion leveraging existing platform features (or even theoretical ones) can potentially get us higher reward with less work. I am quite sure by the time mesh gradients are implemented someone will have a blurhash style technique just using these; is that enough?
jakearchibald commentedon Sep 23, 2026
Barry Pollard (@tunetheweb) I just posted about progressive in #1401 (comment) since that seems to be the general "why?" issue.
captainbrosset commentedon Sep 23, 2026
That would definitely work for me.
felixicaza commentedon Sep 29, 2026
I agree with this.
I've been using LQIP-based techniques for a few years, and it’s really great to see a native proposal for their implementation. I agree that BlurHash is a useful starting point, but there are several approaches to generating image previews, beyond those already mentioned here, and the differences between them can be quite significant.
ThumbHash was specifically designed as an alternative to BlurHash, as it provides more information and allows for encoding more detail while taking up virtually the same amount of space, all while preserving aspects such as aspect ratio, greater color fidelity, and the alpha channel. There are also very different approaches, such as SQIP which uses SVG primitives, Gradify which is based on CSS linear gradients, or CSS-only LQIP by Lean Rada based on radial gradients.
I find these methods interesting precisely because they involve different trade-offs; while some approaches are less robust in terms of the information they provide while the high-resolution image loads, I believe that the best preview may depend largely on the image and the context. Therefore, I would consider BlurHash simply as one more option within a range of techniques already explored by developers.
ogerchikov commentedon Oct 2, 2026
Thanks for the suggestions to use gradients and other CSS-generated images as previews.
The current proposal does not support these values directly.
previewsrcaccepts a URL, while gradients and similar values use the CSS<image>syntax.Authors can use a gradient as the background of an
<img>, or create an SVG or raster image with a similar appearance and reference it frompreviewsrc. However, these are workarounds and are not the same as allowing a CSS image to be used directly as the preview.Supporting CSS images directly would require a CSS property or another CSS integration. We would also need to define when the CSS preview is replaced and how it interacts with the image and transitions.
I think this is an important limitation of the proposed API, and it is not clear enough in the current explainer. I will update the explainer to mention it explicitly and describe CSS-image support as a possible separate or companion feature.
Clarify CSS image support in the Image Preview explainer (#1412)
Document `lowsrc` prior art for Image Preview (#1411)
jakearchibald commentedon Oct 2, 2026
I suggested an approach in #1405 that would work better with things like CSS gradients.
Th3S4mur41 commentedon Oct 5, 2026
Setting the background image as preview might lead to unwanted results once the image is loaded, especially if the image contains transparent parts. For this to work, we'd need img state pseudo-classes to remove/hide the background once the image is properly loaded
jakearchibald commentedon Oct 5, 2026
fwiw I'm discussing that over in #1405
Th3S4mur41 commentedon Oct 5, 2026
This is a different approach.
#1405 is adding new pseudo-class to explicitly handle a dedicated preview source.
My suggestion above was rather about using existing feature like background image to display the preview and use state pseudo-classes to hide it when the image is loaded.
This solution would have the advantage that it doesn't require new attributes but probably has disadvantage to the proposed solution here that you know better than me
jakearchibald commentedon Oct 5, 2026
#1405 (comment) - this covers why putting a background on the image isn't enough.
Additionally, imagine the image is a WebP with transparency. These render top-to-bottom. What would you do whilst 10% of the main image has rendered? It would either render on top of your background image, or you'd hide the background image, meaning you've switched from a full preview to 10% of the image.