Loading Choreography (4 Before/After Pairs) new 加载体验(4 组对比) web
How content arrives matters as much as how long it takes: skeleton shimmer, blur-up images, early load-more and streamed AI replies, each against its common shortcut
内容怎么到场和要等多久一样重要:骨架屏扫光、图片模糊到清晰、提前加载更多、AI 流式回复,各配一个常见偷懒写法对比
✕Common
✓Better
标本可交互,可以直接操作。
Anatomy — every part, named解剖 —— 每个部件的名字
-
1 Skeleton shimmer骨架屏扫光
@keyframesPlaceholder shapes of the real layout with light sweeping across; content then surfaces block by block.
按真实布局摆好占位形状,光从上面扫过,内容再一块块露出来。
Prompt fragmentPrompt 片段a skeleton matching the layout, a shimmer sweep, and a staggered reveal of real content
与布局一致的骨架屏、扫光,以及真实内容依次出场
-
2 Blur-up image图片模糊到清晰
aspect-ratio + blur()A reserved box with a blurred placeholder in the image's colours that focuses into the real image.
预留好位置,先铺同色的模糊占位,再对焦成真实图片。
Prompt fragmentPrompt 片段reserved image boxes with blurred colour placeholders that sharpen without layout shift
预留图片框,同色模糊占位慢慢变清晰,版面不跳
-
3 Early load-more提前加载更多
IntersectionObserverFetching starts before the end of the list; items join one by one while scrolling continues.
还没到列表底部就开始加载,新内容一件件接上,滚动不停。
Prompt fragmentPrompt 片段a sentinel a few items before the end that starts loading, bouncing dots, items appended one at a time
距底部几项处放哨兵开始加载,跳动小点,逐个追加
-
4 Streamed AI replyAI 流式回复
ReadableStreamThe bubble appears at once with breathing dots, then paragraphs rise in and the view follows.
气泡立刻出现、小点在呼吸,回复一段段浮出,页面跟着走。
Prompt fragmentPrompt 片段an immediate reply bubble with breathing dots, streamed paragraphs, and a view that follows new text
立刻出现带呼吸点的气泡,分段流式出现,页面跟随新内容
Prompt — paste into your agentPrompt —— 直接粘贴给你的代理
Design the loading experience, not just a spinner, for four cases: 1 Lists and cards: render a skeleton that matches the final layout and sweep a soft shimmer across it, then reveal real content block by block with a short stagger, like a tide going out, never all at once after a spinner. 2 Images: reserve each image's box with aspect-ratio, fill it with a blurred placeholder in the image's own colours, then animate from blur to sharp like a camera focusing, with zero layout shift. 3 Infinite lists: start fetching the next page while the user is still a few items from the end (IntersectionObserver with a large rootMargin), show three small bouncing dots, and append items one by one so scrolling never stops. 4 AI replies: show the reply bubble immediately with breathing dots, stream the answer and reveal it paragraph by paragraph, and keep the view following the newest text unless the user scrolls up. Honour prefers-reduced-motion.
把加载做成一套体验,而不只是一个转圈,分四种情况:1 列表和卡片:先渲染和最终布局一致的骨架屏,上面扫过一道柔和的光,然后真实内容按顺序一块块浮出来,像退潮一样,不要转完圈一下子全部出现。2 图片:用 aspect-ratio 先占好每张图的位置,填上和图片同色的模糊占位,再像相机对焦一样从模糊变清晰,版面完全不跳。3 无限列表:用户离底部还有几项时就开始请求下一页(IntersectionObserver 加大 rootMargin),显示三个跳动的小点,新内容一件件接上,滚动不停。4 AI 回复:一发送就立刻出现回复气泡和呼吸的小点,流式返回后一段段浮出,页面跟着最新内容往下走,除非用户自己往上翻。尊重 prefers-reduced-motion。
Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时
Debug my loading states. Check that skeleton blocks match the final layout so nothing moves when content arrives; the shimmer stops once a block is ready; image boxes have aspect-ratio or explicit dimensions so there is no layout shift; the blur placeholder uses the image's colours and is replaced, not stacked; the load-more sentinel fires early enough that users never hit a dead end, and requests are not duplicated; streamed AI text appends without re-rendering the whole message, the view follows new text but stops following when the user scrolls up; and reduced motion removes shimmer and slide-ins. The symptom:
调试我的加载状态。检查:骨架屏是否和最终布局一致,内容到了之后没有东西移动;内容准备好后扫光是否停止;图片框是否设了 aspect-ratio 或明确尺寸,没有版面跳动;模糊占位是否取自图片本身的颜色,并且是被替换而不是叠在一起;加载更多的哨兵是否触发得足够早,用户永远碰不到尽头,且请求不重复;AI 流式文字是否追加而不是整段重绘,页面是否跟随新内容、用户往上翻时停止跟随;以及减少动态效果时是否去掉扫光和滑入。症状是:
In code代码里叫什么
| Framework框架 | Symbol符号 | Note说明 |
|---|---|---|
| CSS | @keyframes + linear-gradient | the skeleton shimmer: a highlight band sweeping across placeholder blocks骨架屏扫光:一道高光在占位块上扫过 |
| CSS | aspect-ratio + filter: blur() | blur-up: reserve the image box, show a blurred tiny placeholder, then sharpen模糊到清晰:先占好图片位置,显示模糊的小图,再变清晰 |
| Web | IntersectionObserver rootMargin | load more early: observe a sentinel well before the end of the list提前加载:在列表末尾之前很远就开始监听哨兵元素 |
| Web | ReadableStream / Server-Sent Events | stream the AI reply and render it chunk by chunk流式返回 AI 回复,一段段渲染 |
| Web | BlurHash / ThumbHash | compact placeholders that decode to the image's colours把图片颜色压缩成很小的占位图 |