-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
50 lines (37 loc) · 1.39 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: "PerformanceElementTiming: url property"
short-title: url
slug: Web/API/PerformanceElementTiming/url
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.PerformanceElementTiming.url
---
{{APIRef("Performance API")}}{{SeeCompatTable}}
The **`url`** read-only property of the {{domxref("PerformanceElementTiming")}} interface returns the initial URL of the resource request when the element is an image.
## Value
A string which is the initial URL of the resources request for images or `0` for text.
## Examples
### Logging `url`
In this example an {{HTMLElement("img")}} element is being observed by adding the [`elementtiming`](/en-US/docs/Web/HTML/Attributes/elementtiming) attribute. A {{domxref("PerformanceObserver")}} is registered to get all performance entries of type `"element"` and the `buffered` flag is used to access data from before observer creation. Calling `entry.url` returns `https://example.com/image.jpg`.
```html
<img
src="https://example.com/image.jpg"
alt="a nice image"
elementtiming="big-image"
id="myImage" />
```
```js
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.identifier === "big-image") {
console.log(entry.url);
}
});
});
observer.observe({ type: "element", buffered: true });
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}