The clearMarks() method removes all or specific PerformanceMark objects from the browser's performance timeline.
On this page
Performance: clearMarks() method
Syntax
js
clearMarks()
clearMarks(name)
Parameters
nameOptional-
A string representing the
nameof thePerformanceMarkobject. If this argument is omitted, all entries with anentryTypeof "mark" will be removed.
Return value
None (undefined).
Examples
Removing markers
To clean up all performance marks, or just specific entries, use the clearMarks() method like this:
js
// Create a bunch of marks
performance.mark("login-started");
performance.mark("login-started");
performance.mark("login-finished");
performance.mark("form-sent");
performance.mark("video-loaded");
performance.mark("video-loaded");
performance.getEntriesByType("mark").length; // 6
// Delete just the "login-started" mark entries
performance.clearMarks("login-started");
performance.getEntriesByType("mark").length; // 4
// Delete all of the mark entries
performance.clearMarks();
performance.getEntriesByType("mark").length; // 0
Specifications
| Specification |
|---|
| User Timing # dom-performance-clearmarks |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
clearMarks |
2925–29 | 12 | 38 | 10 | 33 | 11 | 4.4 | 2925–29 | 42 | 33 | 11 | 2.01.5–2.0 |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Performance/clearMarks