Story Details

  • Minimal CSS-only blurry image placeholders

    Posted: 2025-03-30 11:11:35

    The blog post demonstrates a technique for creating lightweight, CSS-only low-quality image placeholders (LQIPs) using a combination of base64 encoded, heavily compressed, blurred versions of the final image embedded directly within the CSS. This method avoids extra HTTP requests and JavaScript, offering a performant way to improve the perceived loading experience. The blurred image is scaled up and positioned as a background, while the actual high-resolution image loads in the foreground. Once the full image loads, it covers the placeholder seamlessly. This approach provides a smoother visual transition and eliminates the jarring "pop-in" effect often seen with other placeholder methods.

    Summary of Comments ( 53 )
    https://news.ycombinator.com/item?id=43523220

    HN users generally praised the technique described in the article for its simplicity and minimal code footprint. Several commenters appreciated the avoidance of JavaScript, leading to improved performance, particularly on mobile devices. Some pointed out potential drawbacks, such as the doubled image payload and a slight flash of unstyled content (FOUC) if the CSS loads after the image. A few users suggested alternative approaches, including inline SVG blur filters and using the background-image property instead of <img> tags for placeholders, while acknowledging trade-offs related to browser compatibility and control over the blurring effect. Overall, the discussion highlighted the ongoing search for efficient and elegant image placeholder solutions, with this CSS-only technique seen as a valuable addition to the developer's toolkit.