A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

[Proposal] Element Timing


The Element Timing API provides timing on when elements are displayed. This first proposal is restricted to <img> elements to make it simpler:


What would this do that an Intersection Observer doesn’t allow for? You can use an Intersection Observer to know when a node is in the active viewport. And then do something based on that event. It sounds exactly like what your intended goal is, except far more widely applicable to web applications.


The main reason this is preferred over Intersection Observer is because we want to avoid forcing developers to run Javascript very early in the page load. You’d need to run a script that registers the Intersection Observer very early on for it to work. This would not be required with Element Timing because the PerformanceObserver could be created with a buffered flag that provides values measured before its creation.

Also, IntersectionObserver wouldn’t be ergonomic for this use case: handling the question of when the element has loaded, wanting only the first update for the element, etc.


We are still interested in moving forward with the proposal and have evolved it a bit.


As part of the origin trial, we prototyped a plugin to collect the new Element Timing data. And we have a few ideas for features built on top of this data.

We anxiously await ET landing in Chrome by default!


Since there seems to be some support to this feature, I’d like to move the repo to WICG and continue incubating it from there. I’ll have a spec to accompany the explainer soon.


Thank you for incubating WICG! :slight_smile: The repo has now moved and is at https://github.com/WICG/Element-Timing