aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/performanceelementtiming/url/index.md
blob: bc22f2c6e633274ce23e8b3fa6cef519b304f211 (plain)
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
51
52
53
54
55
56
---
title: PerformanceElementTiming.url
slug: Web/API/PerformanceElementTiming/url
tags:
  - API
  - Property
  - Propriété
  - Reference
  - url
  - PerformanceElementTiming
translation_of: Web/API/PerformanceElementTiming/url
---
{{APIRef("Element Timing API")}}

La propriété en lecture seule **`url`** de l'interface [`PerformanceElementTiming`](/fr/docs/Web/API/PerformanceElementTiming) renvoie l'URL initiale de la demande de ressource lorsque l'élément est une image.

## Syntaxe

```js
var url = PerformanceElementTiming.url;
```

### Valeur

Une [`DOMString`](/fr/docs/Web/API/DOMString) qui est l'URL initiale de la demande de ressources pour les images ou 0 pour le texte.

## Exemples

Dans cet exemple, appeler `entry.url` renvoie `https://example.com/image.jpg`.

```html
<img src="https://example.com/image.jpg" alt="une belle imahe" elementtiming="big-image" id="myImage">
```

```js
const observer = new PerformanceObserver((list) => {
  let entries = list.getEntries().forEach(function (entry) {
    if (entry.identifier === "big-image") {
      console.log(entry.url);
    }
  });
});
observer.observe({ entryTypes: ["element"] });
```

> **Note :** Cet exemple utilise l'interface [`PerformanceObserver`](/fr/docs/Web/API/PerformanceObserver) pour créer une liste d'événements de mesure des performances. Dans notre cas, nous observons l'élément [`PerformanceEntry.entryType`](/fr/docs/Web/API/PerformanceEntry/entryType) afin d'utiliser l'interface `PerformanceElementTiming`.

## Spécifications

| Spécification                                                                                                                            | Statut                                   | Commentaire          |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | -------------------- |
| {{SpecName('Element Timing API','#dom-performanceelementtiming-url','PerformanceElementTiming.url')}} | {{Spec2('Element Timing API')}} | Définition initiale. |

## Compatibilité des navigateurs

{{Compat("api.PerformanceElementTiming.url")}}