The containertiming global attribute marks an element as a container root, for which PerformanceContainerTiming entries can be observed by PerformanceObserver objects using the "container" type.
Any paints to new areas inside the container root's subtree contribute to the container's timing (content painted inside the container root itself is excluded, as are repaints to already painted areas).
Timing entries are reported only until the user scrolls or interacts with the page.
Descendant subtrees can be excluded from a container's timing using the containertimingignore attribute.
For more details, see the PerformanceContainerTiming interface.
In the DOM, this attribute is reflected as HTMLElement.containerTiming.
Value
A string that identifies the container. This is returned in PerformanceContainerTiming.identifier.
Examples
Marking a container root
This example marks two elements as container roots, identified as "hero" and "product-list".
<section containertiming="hero">
<h1>Welcome</h1>
<img src="hero.jpg" alt="" />
</section>
<div containertiming="product-list">
</div>
Specifications
Browser compatibility
See also
containertimingignore- PerformanceContainerTiming
- HTMLElement.containerTiming
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
