M4RKYU.SYSEdition 2027
Skip to content
LOCZH/安大略 · 加拿大/▸logs · zero cls images in nextjs 16 lqip blur up done right 1nkb待机OK/--:--:--EST
M4M4RK_YUportfolio
  • 创作创作
    创作Overview
    • 作品精选案例与项目记录
    • 游戏可玩原型与游戏开发日志
  • 影像影像
    影像Overview
    • 照片影像合集与视觉实验
    • 商店印刷品、海报和限量物件
  • 写作写作
    写作Overview
    • 博客长篇开发日志与现场笔记
    • 笔记短观察、链接与代码片段
  • 资源资源
    资源Overview
    • 工具38 款浏览器内开发工具
    • 链接每日使用的开发与设计书签
  • 关于关于
  • 联系联系
EN

同步 · dev.to / @markyu

Next.js Images Without CLS: My LQIP Blur-Up Setup

A practical Next.js image optimization guide for zero CLS layouts, blur placeholders, dimensions, remote images, and production image hygiene.

发布日期
Jun 4
·
阅读时长
2 min read
·
点赞
6
nextjsperformancereactwebdev
在 dev.to 查看

本页目录

  • The Rule
  • Local Image Example
  • Remote Image Example
  • CSS Must Not Break the Ratio
  • Production Checklist
  • My Take on LQIP
  • Final Thought

Image layout shift is one of those bugs that makes a page feel cheap.

The content loads, the image arrives late, the text jumps, and the user loses their place.

In Next.js, the fix is not complicated: give the browser stable dimensions and use a placeholder only as polish, not as a layout crutch.

The Rule

No known image box -> layout shift risk
Known width/height -> stable layout
Blur placeholder -> nicer loading

Local Image Example

import Image from "next/image";
import hero from "@/public/hero.jpg";

export default function Hero() {
  return (
    <Image
      src={hero}
      alt="Dashboard showing image performance metrics"
      priority
      placeholder="blur"
      sizes="100vw"
      className="heroImage"
    />
  );
}

For static imports, Next.js can infer dimensions and generate blur data.

That is the easiest path.

Remote Image Example

Remote images need explicit dimensions:

<Image
  src="https://example.com/product.jpg"
  alt="Product preview"
  width={1200}
  height={800}
  placeholder="blur"
  blurDataURL={blurDataUrl}
  sizes="(max-width: 768px) 100vw, 720px"
/>

If you do not know the dimensions, fetch or store them before render. Guessing is how CLS sneaks back in.

CSS Must Not Break the Ratio

.heroImage {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
}

Avoid setting random height without thinking about aspect ratio.

Production Checklist

CheckWhy
width and height setprevents layout shift
meaningful altaccessibility
sizes accurateavoids oversized downloads
priority only for heroavoids stealing bandwidth
blur placeholder smallavoids bloated HTML
remote domains configuredavoids runtime failures

My Take on LQIP

LQIP is not the main performance feature. It is a perceived performance feature.

The real layout fix is reserving the image box.

Blur-up makes the wait feel smoother, but it will not save a layout that does not know its own dimensions.

Final Thought

Zero CLS images are mostly discipline: dimensions, ratios, correct sizes, and not treating placeholders as magic.

What image bug has caused the most layout pain in your Next.js projects?

相关阅读

React 19 Micro-Interactions Without Layout Jank

A practical React 19 micro-interactions guide focused on motion boundaries, CSS transitions, optimistic UI, reduced motion, and performance.

react

JavaScript Memory Leaks Usually Start With One Reference

A practical JavaScript memory guide covering stack, heap, garbage collection, closures, event listeners, timers, and leak debugging.

javascript

React Three Fiber: Build a 3D Scene Without Fighting React

A code-first React Three Fiber setup with lighting, controls, materials, and the mistakes that make your first scene render black.

react

原文发布

本文首发于 dev.to,评论与点赞保留在原站。

在 dev.to 继续阅读
上一篇Bad Data Quality Costs More Than a Slow QueryA practical data quality guide for engineers: validation, ownership, schema drift, observability, and fixing bad data before dashboards lie.
返回全部文章
下一篇Free 3D Asset Sites I’d Actually Use in a WebGL ProjectA practical 2026 guide to free 3D asset sources for games, Blender, and WebGL, with license checks, optimization tips, and production workflow advice.
返回档案
M4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYU
始于 2024
ZhenXiao Mark YuZhenXiao Mark Yu
联系

看到什么有意思的?和我聊聊。

这是一个作品集,不是服务 · 但每一条留言我都会看 — 如果哪里让你有所触动,或者只想打个招呼,欢迎写信过来。

开启对话
频道开放

随时打个招呼 · 2026

--:--:--EST加拿大 安大略
  • 邮件
  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat

订阅

偶尔收到一封简讯

来自 m4rkyu.com 的笔记与日志——简短、标注日期、没有杂音。随时可退订。

作品

线上发布、游戏作品与视觉档案。

  • 项目
  • 游戏
  • 档案
  • 日志

资源

每日好用的工具与个人收藏的链接库。

  • 搜索
  • 最新
  • 工具
  • 链接
  • 笔记
  • 主题
  • 商店
RSSJSON Feed

工作室

背景、联系方式以及合作渠道。

  • 关于
  • 联系
  • 更新日志
  • 技术说明
  • 简历筹备中

社交

在常去的平台上找到我。

  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
  • 邮件
© 2026 ZhenXiao Mark Yumarkyu0615@gmail.com
  • 邮件
  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
隐私条款由 Next.js 16 · React 19 · Tailwind 4 构建