[Proposal] Element Timing


#1

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


#2

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.


#3

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.