@unpic/placeholder
This is a library for generating low quality image placeholders by extracting the dominant color from image or server-side rendering a BlurHash. These are displayed while an image is loading, and give better appearance and can help reduce the LCP time. It can render a Blurhash to either a set of CSS gradients, or a tiny BMP image data URI. These are usually both around 150 bytes in size, and can be applied as a CSS background image to the img element. For more details, see the README.
Try it out by clicking one of the examples or choosing your own image. The placeholder images are then displayed below.
blurhashToCssGradientString
. Bytes: 603 Gzipped 172
Gradient CSS
blurhashToDataUri
. Bytes: 142. GZipped 126
BMP URI
LQIP
. Bytes: 0. GZipped 0
LQIP URI
Dominant color
imageToCssGradient
. Bytes: 0. GZipped 20
CSS Gradient
CSS Variables
. Bytes: 0. GZipped 20