← Back to release summary

'pagereveal' event

Category
DOM
Type
New or changed feature
Status
Enabled by default (Chrome 123)
Intent stage
None

Summary

The `pagereveal` event is fired on a Document's window object at the first render opportunity after a Document is: initially loaded, restored from the back-forward cache, or activated from a prerender. It can be used by a page author to setup a page entry UX - such as a ViewTransition from a previous state. This feature is split out from the larger ViewTransition-on-Navigation project.

Motivation

This event enables authors to make last-minute DOM changes once a document is ready to be presented but before it is rendered. It is fired on first load as well as when restoring a persisted BFCache'd page or activating a prerendered page. In particular, this enables an author to setup their style for a ViewTransition, if one is available, from a single convenient place. Without it, authors would have to do this from a `requestAnimationFrame` and also remember to add listen to `pageshow.persisted` to handle the BFCache case, which is error prone. This event is also how a cross-document ViewTransition object is passed into the incoming Document.

Standards & signals

Docs: https://github.com/WICG/view-transitions/blob/main/cross-doc-explainer.md

Explainers: https://github.com/WICG/view-transitions/blob/main/cross-doc-explainer.md

View on chromestatus.com