Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The JS Self-Profiling API enables a website to run a sampling profiler, to understand where it is spending JavaScript execution time.
To start a profile, a website creates a Profiler instance. As soon as the instance is created, it starts sampling the JavaScript execution context.
To stop collecting samples and retrieve the profile, the website calls Profiler.stop(). This returns a Promise which resolves to an object containing the profile data.
For example, the following function creates a profiler, then calls a function genPrimes(), then stops the profiler and retrieves the profile data:
The profiler is a sampling profiler: this means that it periodically records (or samples) the current state of the JavaScript call stack. The profile consists of the collection of these samples. This enables you to understand where, statistically, the program is spending most of its time.
To understand exactly what a profile contains and how it is formatted, see Profile anatomy and format.
Collecting and processing profile data incurs a performance overhead of its own, and developers should be careful to manage this. Practices to minimize performance overhead include:
If the JavaScript in your site is minified, you will need to transform the profile data based on a source map, either on the client or on the server, before the data will be usable.
The Profiler interface is used to create profiles.
To use this API, the document must be served with a document policy that includes the "js-profiling" configuration point.
| JS Self-Profiling API |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jun 23, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.