Skip to content

Commit 38044b3

Browse files
noamrvmpstr
andauthored
[css-view-transitions-2] Add example and note for render-blocking (w3c#10170)
* [css-view-transitions-2] Add example and note for render-blocking * Update css-view-transitions-2/Overview.bs Co-authored-by: vmpstr <vmpstr@chromium.org> --------- Co-authored-by: vmpstr <vmpstr@chromium.org>
1 parent f9c1622 commit 38044b3

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,46 @@ See the <a href="#lifecycle">lifecycle</a> section for more details.
139139

140140
### Waiting for the new state to stabilize ### {#waiting-for-stable-state}
141141
In same-document view transitions, the author can indicate when the new state of the transition is in a stable state by using the callback passed to {{Document/startViewTransition}}.
142-
Since cross-document view transitions are declarative, there is no such explicit promise. Instead, the user agent relies on the [=render-blocking mechanism=] to decide when the stable state is ready.
142+
Since cross-document view transitions are declarative, there is no such explicit promise. Instead, the user agent relies on the [=render-blocking mechanism=] to decide when the document has reached a stable state.
143143
In this way, the author can use the the <code data-x="">blocking</code> attribute, to delay the transition until:
144144
* All expected scripts are executed, by using the script's {{HTMLScriptElement/blocking}} attribute on required scripts.
145145
* All expected styles are executed, by using the style or link's {{HTMLStyleElement/blocking}} attribute on required styles.
146146
* All expected HTML elements are seen by the parser, using an <{link/rel/expect}> {{HTMLLinkElement}} element.
147147

148+
Note: overusing the render-blocking mechanism could make it so that the old state remains frozen for a long time, resulting in a jarring user experience.
149+
To avoid this, it's advised to ensure that the render-blocking elements are available in a timely manner.
150+
148151
<div class="example">
152+
153+
In this example, the last frame of the old document will be shown, and the animation will be delayed, until all the following conditions are met:
154+
- `style.css` is applied, to ensure the new state has the correct styles
155+
- `fixup.js` is run, to ensure the presentation is up to date with script-based fixups.
156+
- The `main-article` section is seen and parsed, to ensure enough of the content is loaded before allowing the transition to proceed.
157+
158+
```html
159+
<!DOCTYPE html>
160+
<html>
161+
<head>
162+
< !-- This will be render-blocking by default -->
163+
<link rel="stylesheet" href="style.css">
164+
165+
< !-- Since this script fixes up the layout, marking it as render blocking will
166+
ensure it's run before the view transition is activated -->
167+
<script async href="fixup.js" blocking="render"></script>
168+
169+
< !-- Wait until the main-article element is seen and fully parsed before
170+
activating the transition -->
171+
<link rel="expect" href="#main-article" blocking="render">
172+
</head>
173+
<body>
174+
<header>...</header>
175+
<main>
176+
<article id="main-article">...</article>
177+
</main>
178+
<article id="secondary-article">...</article>
179+
</body>
180+
</html>
181+
```
149182
</div>
150183

151184
### Customization ### {#customizing-cross-document-view-transitions}

0 commit comments

Comments
 (0)