JA EN

Image Placeholder Techniques Compared - LQIP, BlurHash, and SQIP Implementation Guide

· 9 min read

What Are Image Placeholders - Why They're Better Than Blank Space

Image placeholders are alternative content displayed while the actual image is loading. On pages implementing lazy loading, images outside the viewport have their loading deferred, which can cause momentary blank spaces during scrolling. Filling these blanks with placeholders significantly improves user experience.

Problems without placeholders:

Placeholder types fall into four main categories:

The choice depends on balancing data size, visual quality, implementation complexity, and performance impact. The following sections compare each technique in detail.

Implementing LQIP - Preview Display with Tiny Images

LQIP (Low Quality Image Placeholder) embeds an extremely downsized, low-quality version of the original image inline in HTML. It became widely known after Facebook adopted it around 2015. When browsers upscale the tiny image, natural blur effects occur, making it function as a placeholder without additional CSS filters.

Implementation steps:

Data size guidelines: A 20px-wide JPEG (quality 20) is approximately 300-600 bytes. Base64 encoded, this becomes about 400-800 characters. Even embedded directly in HTML, the impact per image stays under 1KB.

Enhanced blur with CSS: Browser bilinear interpolation alone may show visible block artifacts. Applying filter: blur(20px) and transitioning it off when the image loads produces smoother results:

.lqip { filter: blur(20px); transform: scale(1.1); transition: filter 0.3s, transform 0.3s; }
.lqip.loaded { filter: blur(0); transform: scale(1); }

LQIP's advantages are implementation simplicity and no special library requirements. It's easily generated with Sharp or ImageMagick and integrates smoothly into existing build pipelines.

How BlurHash Works - An Innovative String-Based Image Representation

BlurHash is an algorithm developed by Wolt (a Finnish food delivery company) that encodes images into short strings of approximately 20-30 characters. Since blurred images are generated client-side from this string, there's no need to transfer image data like LQIP does.

Encoding principle: BlurHash decomposes images into frequency components using Discrete Cosine Transform (DCT), retaining only low-frequency components. The number of components (X direction x Y direction) is configurable, defaulting to 4x3. Each component's coefficients are encoded in Base83 to produce the string.

Decoding flow:

Data size: With 4x3 components, just 20 characters (approximately 20 bytes) can represent the image's general color distribution. This is 10-30x more compact than LQIP's 300-600 bytes. Including it in JSON API responses has virtually zero bandwidth impact.

Implementation example (JavaScript decode):

import { decode } from 'blurhash';
const pixels = decode('LEHV6nWB2yk8pyo0adR*.7kCMdnj', 32, 32);
// pixels is Uint8ClampedArray (32*32*4 = 4096 elements)
// Set as Canvas ImageData to render

BlurHash is adopted by Instagram, Mastodon, Unsplash, and many other services. It's ideal for including hash strings in API responses to display placeholders before image URLs finish loading.

SQIP Features - Artistic Placeholders with SVG Primitives

SQIP (SVG-based Quality Image Placeholder) approximates images using combinations of SVG primitive shapes (triangles, ellipses, rectangles, etc.). Published by Tobias Baldauf in 2017, it internally uses the Primitive algorithm by Michael Fogleman.

Generation process:

Data size: Approximately 800-1200 bytes with 8 primitives. Similar to LQIP, but since SVG is vector-based, it displays sharply at any resolution. No blurriness on Retina displays.

Visual quality: SQIP's greatest feature is its aesthetic beauty as a placeholder. The combination of geometric shapes creates an artistic impression, producing more design-forward placeholders than simple blurred images. It's well-suited for portfolio and gallery sites where visual quality matters.

SQIP's challenges: Slow generation time is the primary weakness. Processing takes 1-5 seconds per image, significantly increasing build times for sites with many images. Additionally, the Node.js sqip package has stagnating maintenance, occasionally causing compatibility issues with newer Node.js versions.

As an alternative, you can use the primitive command-line tool directly and manually add blur filters to the output SVG. Being implemented in Go, it runs quickly.

Comparison and Selection Criteria - Choosing the Best Technique for Your Project

Here's a comparison of the four placeholder techniques across key evaluation dimensions. Select the optimal technique based on your project's requirements.

Data size comparison:

Visual quality (information richness): SQIP > LQIP > BlurHash > Dominant color. SQIP best preserves image structure, LQIP naturally represents color distribution. BlurHash reproduces approximate color gradients but loses edge information.

Generation speed: Dominant color (under 1ms) > BlurHash (10-50ms) > LQIP (50-200ms) > SQIP (1-5 seconds). In build pipelines processing many images, SQIP's generation time can become a bottleneck.

Recommended use cases:

Combining multiple techniques is also effective. For example, using LQIP for above-the-fold images and only dominant colors for below-the-fold images is a practical graduated approach.

Implementation with Next.js and Astro - Integration with Modern Frameworks

Modern web frameworks provide mechanisms for efficiently integrating placeholder generation and display. Here are concrete implementation methods for Next.js and Astro.

Next.js Image component: Next.js's <Image> component natively supports LQIP and BlurHash via the placeholder prop:

<Image src="/photo.jpg" placeholder="blur" blurDataURL="data:image/jpeg;base64,..." />

For static imports, blurDataURL is automatically generated at build time. For dynamic images, use the plaiceholder library for server-side generation:

import { getPlaiceholder } from 'plaiceholder';
const { base64 } = await getPlaiceholder('/photo.jpg');

Astro implementation: Astro's <Image> component doesn't have direct placeholder support, but generating LQIP with Sharp at build time and passing it to components is the common pattern:

import sharp from 'sharp';
const buffer = await sharp('src/images/photo.jpg').resize(20).jpeg({ quality: 20 }).toBuffer();
const lqip = `data:image/jpeg;base64,${buffer.toString('base64')}`;

BlurHash React implementation: The react-blurhash package easily displays Canvas-based placeholders from BlurHash strings. Combining with Intersection Observer to load actual images when entering the viewport is effective.

Performance considerations: Inline Base64 images increase HTML size, so SSR pages need to watch initial HTML transfer volume. For pages with 50+ images, set only dominant colors for below-the-fold images and limit LQIP to the 5-10 images near the first viewport.

Related Articles

Image Lazy Loading Implementation Guide - Choosing Between loading=lazy and IntersectionObserver

Learn how to improve web page initial load speed with image lazy loading, covering both native API and JavaScript approaches with practical examples.

Image Loading Strategy Design - Mastering preload, fetchpriority, and decoding

Deep dive into three HTML attributes that optimize image loading. Learn the correct usage and combinations of preload, fetchpriority, and decoding for LCP improvement.

Embedding Images with Data URIs - Base64 Encoding Mechanics and Best Practices

Learn how Data URI scheme embeds images directly in HTML/CSS. Understand Base64 encoding mechanics, performance implications, appropriate use cases, and when to avoid inline images.

Image Gallery Performance Optimization - Techniques for Fast Display of Large Collections

Optimize performance for gallery pages with hundreds of images. Covers virtual scrolling, progressive loading, memory management, and efficient layout calculation with practical implementations.

Web Image Performance Audit - Practical Guide to Core Web Vitals Improvement

Learn how to audit image impact on web performance. Covers LCP improvement, CLS prevention, and transfer size reduction with actionable techniques.

SVG Fundamentals and Practical Usage - From Vector Basics to Animation

Complete guide to SVG from basic structure to practical applications. Learn paths, shapes, text, filters, animation implementation, and optimization techniques for web development.

Related Terms