PerformanceElementTiming: loadTime property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
TheloadTime read-only property of thePerformanceElementTiming interface always returns0 for text. For images it returns the time which is the latest between the time the image resource is loaded and the time it is attached to the element.
In this article
Value
ADOMHighResTimeStamp with theloadTime of the element. Always0 for text.
Examples
>LoggingloadTime
In this example an<img> element is being observed by adding theelementtiming attribute. APerformanceObserver is registered to get all performance entries of type"element". Thebuffered flag is used to access data from before the observer was created. Callingentry.loadTime returns the loadTime of the image element.
<img src="image.jpg" alt="a nice image" elementtiming="big-image" />const observer = new PerformanceObserver((list) => { list.getEntries().forEach((entry) => { if (entry.identifier === "big-image") { console.log(entry.loadTime); } });});observer.observe({ type: "element", buffered: true });Specifications
| Specification |
|---|
| Element Timing API> # dom-performanceelementtiming-loadtime> |