performance.mark
Creates a named performance entry with a high-resolution timestamp in the browser's performance timeline
Syntax
performance.mark(name, options?)Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the mark |
| options | PerformanceMarkOptions | Optional object with detail and startTime |
Return Value
A PerformanceMark object
Examples
performance.mark('start-fetch')
await fetch('/api/data')
performance.mark('end-fetch')
const measure = performance.measure('fetch-duration', 'start-fetch', 'end-fetch')
console.log(`Fetch took ${measure.duration}ms`)performance.mark('render-start')
// ... render logic
performance.mark('render-end')
performance.measure('render', 'render-start', 'render-end')performance.mark('page-interactive', {
detail: { route: '/home' }
})
console.log(performance.getEntriesByName('page-interactive'))Understanding performance.mark
The performance.mark method in JavaScript creates a named performance entry with a high-resolution timestamp in the browser's performance timeline. It belongs to the Performance object and is one of the most widely used methods for working with performance values in modern JavaScript and TypeScript applications.
The method signature is performance.mark(name, options?). It accepts 2 parameters: name, options. When called, it returns a performancemark object. Understanding when and how to use mark() helps you write more expressive, readable code.
Common use cases for performance.mark include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like performance-measure, performance-now, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for performance.mark is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More Performance Methods
Other methods in the Performance object
Related Tools
More Performance Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.