PerformanceMark: PerformanceMark() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2022.

Note: This feature is available in Web Workers.

The PerformanceMark() constructor creates a timestamp with the given name.

Unlike performance.mark(), performance marks created by the constructor aren't added to the browser's performance timeline. This means that calls to the Performance interface's getEntries*() methods (getEntries(), getEntriesByName() or getEntriesByType()) won't show entries for these marks.

Syntax

js
new PerformanceMark(name)
new PerformanceMark(name, markOptions)

Parameters

name

A string representing the name of the mark.

markOptions Optional

An object for specifying a timestamp and additional metadata for the mark.

detail Optional

Arbitrary metadata to include in the mark. Defaults to null.

devtools Optional

Some browsers have use a structured devtools object within the detail object as part of an Extensibility API that surfaces these in custom tracks in performance traces. See the Chrome's Extensibility API documentation for more information.

dataType

A string which must be set to marker. Identifies as a marker.

color Optional

Defaults to "primary". Must be one of "primary", "primary-light", "primary-dark", "secondary", "secondary-light", "secondary-dark", "tertiary", "tertiary-light", "tertiary-dark", "error".

properties Optional

Array of key-value pairs. Values can be any JSON-compatible type.

tooltipText Optional

Short description for tooltip.

startTime Optional

DOMHighResTimeStamp to use as the mark time. Defaults to performance.now().

Return value

A PerformanceMark object.

Exceptions

Examples

Creating named markers

The following example shows how PerformanceMark entries are constructed and then aren't part of the browser's performance timeline.

js
new PerformanceMark("squirrel");
new PerformanceMark("monkey");
new PerformanceMark("dog");

const allEntries = performance.getEntriesByType("mark");
console.log(allEntries.length);
// 0

DevTools Extensibility API

For browsers that support the Extensibility API you can use the detail parameter to provide more details in a devtools object that will be used to display this in performance profiles:

js
// Marker indicating when the processed image was uploaded
performance.mark("Image Upload", {
  detail: {
    devtools: {
      dataType: "marker",
      color: "secondary",
      properties: [
        ["Image Size", "2.5MB"],
        ["Upload Destination", "Cloud Storage"],
      ],
      tooltipText: "Processed image uploaded",
    },
  },
});

Specifications

Specification
User Timing
# dom-performancemark-constructor

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
PerformanceMark() constructor
Chrome – Full support
Chrome 76 (Release date: 2019-07-30)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 63 (Release date: 2019-08-20)
footnote Full support
Safari – Full support
Safari 14.1 (Release date: 2021-04-26)
footnote Full support
Chrome Android – Full support
Chrome Android 76 (Release date: 2019-07-30)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Samsung Internet – Full support
Samsung Internet 12 (Release date: 2020-06-19)
footnote Full support
WebView Android – Full support
WebView Android 79 (Release date: 2019-12-17)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14.5 (Release date: 2021-04-26)
footnote Full support
Bun – Full support
Bun 1.0.22 (Release date: 2024-01-10)
footnote Full support
Deno – Full support
Deno 1.2 (Release date: 2020-07-13)
footnote Full support
Node.js – Full support
Node.js 16 (Release date: 2021-04-20)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also