Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).

The mark() method creates a timestamp in the browser's performance entry buffer with the given name. The application defined timestamp can be retrieved by one of the Performance interface's getEntries*() methods (getEntries(), getEntriesByName() or getEntriesByType()).

Note: This feature is available in Web Workers.

The mark's performance entry will have the following property values:

If the name given to this method already exists in the PerformanceTiming interface, SyntaxError is thrown.

Syntax

performance.mark(name);

Arguments

name
A DOMString representing the name of the mark.

Return value

void
 

Example

The following example shows how to use mark() to create and retrieve PerformanceMark entries.

// Create a bunch of marks.
performance.mark("squirrel");
performance.mark("squirrel");
performance.mark("monkey");
performance.mark("monkey");
performance.mark("dog");
performance.mark("dog");

// Get all of the PerformanceMark entries.
const allEntries = performance.getEntriesByType("mark");
console.log(allEntries.length);
// 6

// Get all of the "monkey" PerformanceMark entries.
const monkeyEntries = performance.getEntriesByName("monkey");
console.log(monkeyEntries.length);
// 2

// Clear out all of the marks.
performance.clearMarks();

Specifications

Specification Status Comment
User Timing Level 2
The definition of 'mark()' in that specification.
Working Draft Clarifies mark() processing model.
User Timing
The definition of 'mark()' in that specification.
Recommendation Basic definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
markChrome Full support 28
Full support 28
No support 25 — 28
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 41IE Full support 10Opera Full support 33Safari Full support 11WebView Android Full support YesChrome Android Full support 28
Full support 28
No support 25 — 28
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Full support 42Opera Android Full support 33Safari iOS Full support 11Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

Метки документа и участники

Внесли вклад в эту страницу: gregtatum, mdnwebdocs-bot, adamsanderson, fscholz, chrisdavidmills, abbycar, AndrewGuenther, jpmedley, rolfedh, AFBarstow
Обновлялась последний раз: gregtatum,