blob: e67b1cba7bfbac7fbf9c1d46dc55ea844ebac340 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
---
title: Performance.clearResourceTimings()
slug: Web/API/Performance/clearResourceTimings
translation_of: Web/API/Performance/clearResourceTimings
---
<div>{{APIRef("Resource Timing API")}}</div>
<p>The <strong><code>clearResourceTimings()</code></strong> method removes all {{domxref("PerformanceEntry","performance entries")}} with an {{domxref("PerformanceEntry.entryType","entryType")}} of "<code>resource</code>" from the browser's performance data buffer and sets the size of the performance data buffer to zero. To set the size of the browser's performance data buffer, use the {{domxref("Performance.setResourceTimingBufferSize()")}} method.</p>
<p>{{AvailableInWorkers}}</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox"><em>performance</em>.clearResourceTimings();
</pre>
<h3 id="Arguments">Arguments</h3>
<dl>
<dt>void</dt>
<dd> </dd>
</dl>
<h3 id="Return_Value" name="Return_Value">Return value</h3>
<dl>
<dt>none</dt>
<dd>This method has no return value.</dd>
</dl>
<h2 id="Example">Example</h2>
<pre class="brush: js">function load_resource() {
var image = new Image();
image.src = "https://developer.mozilla.org/static/img/opengraph-logo.png";
}
function clear_performance_timings() {
if (performance === undefined) {
log("Browser does not support Web Performance");
return;
}
// Create a resource timing performance entry by loading an image
load_resource();
var supported = typeof performance.clearResourceTimings == "function";
if (supported) {
console.log("Run: performance.clearResourceTimings()");
performance.clearResourceTimings();
} else {
console.log("performance.clearResourceTimings() NOT supported");
return;
}
// getEntries should now return zero
var p = performance.getEntriesByType("resource");
if (p.length == 0)
console.log("... Performance data buffer cleared");
else
console.log("... Performance data buffer NOT cleared!");
}
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('Resource Timing', '#dom-performance-clearresourcetimings', 'clearResourceTimings()')}}</td>
<td>{{Spec2('Resource Timing')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
<p>{{Compat("api.Performance.clearResourceTimings")}}</p>
</div>
|