v147 · developer trial · workers · performance
JS Profiling in Dedicated Workers
Chrome 147 adds developer trial support for the JavaScript Self-Profiling API (Profiler) inside dedicated workers. The spec already declares the interface [Exposed=(Window, Worker)]; this trial implements the Worker half in Chromium, so worker scripts can collect statistical call-stack samples of their own execution — still gated by Document Policy, whose worker support is tracked separately.
ProfilerAPIForDedicatedWorker (status experimental in runtime_enabled_features.json5, verified 2026-09-27; the ChromeStatus record lists the Finch pair DocumentPolicyInDedicatedWorker,ProfilerAPIForDedicatedWorker). Enable with --enable-blink-features=ProfilerAPIForDedicatedWorker,DocumentPolicyInDedicatedWorker, or turn on everything experimental via chrome://flags/#enable-experimental-web-platform-features — and serve the worker script with Document-Policy: js-profiling. The API surface may change before it ships; do not use in production.
at a glance
| Status in Chrome 147 | Developer trial — filed under “In developer trial (Behind a flag)” in the milestone=147 listing |
|---|---|
| Extends | JS Self-Profiling API (Profiler), on the main thread since Chrome 94 (webstatus.dev) |
| Runtime flag | ProfilerAPIForDedicatedWorker (experimental; “When enabled, dedicated workers can use profiler API” per the flag’s definition comment) |
| Policy gate | Document-Policy: js-profiling on the worker script’s response — see gendn: Document Policy in Dedicated Workers |
| Specification | JS Self-Profiling API — the Profiler interface |
| Explainer | MSEdgeExplainers — Document Policy in Workers (the record’s explainer/doc link) |
| Intent to Prototype | blink-dev thread |
| ChromeStatus | 5159559872249856 — js-profiling in dedicated workers |
| Tracking bug | crbug 482085416 |
Gating and status divergence, both sides reported rather than resolved (fetched 2026-10-06): this page’s eyebrow and glance table present the feature as a Developer trial behind flags in Chrome 147 — the category the milestone=147 listing files it under — while the ChromeStatus record itself reads status “Proposed” with no desktop milestone field, describing the surface as “remaining gated by Document Policy” with worker Document Policy support tracked separately. The cited WICG draft is where that gate is defined — the js-profiling-mode / js-profiling policy values whose absence makes the constructor throw NotAllowedError — which the syntax section documents.
syntax
IDL quoted verbatim from the draft (read 2026-09-27) — note the exposure set already includes Worker; Chrome 147’s trial is Chromium catching up to it for dedicated workers:
[Exposed=(Window, Worker)]
interface Profiler : EventTarget {
readonly attribute DOMHighResTimeStamp sampleInterval;
readonly attribute boolean stopped;
constructor(ProfilerInitOptions options);
Promise<ProfilerTrace> stop();
};
dictionary ProfilerInitOptions {
required DOMHighResTimeStamp sampleInterval;
required unsigned long maxBufferSize;
};
The constructor algorithm already speaks worker: “If globalObject is a Window or a WorkerGlobalScope”, it reads the js-profiling-mode / js-profiling Document Policy values from that global and throws a "NotAllowedError" DOMException when neither authorizes profiling (and a RangeError for a negative sampleInterval). When the sample buffer reaches maxBufferSize, a samplebufferfull event fires on the profiler (an EventTarget) and sampling stops. stop() resolves with the collected ProfilerTrace — the per-member trace format is documented on MDN’s Profiler pages and in the draft; this page documents the v147 worker-exposure delta rather than duplicating them.
why it exists
Many performance-sensitive applications move heavy computation into dedicated workers to keep the main thread responsive — data processing, cryptography, image manipulation, WebAssembly calls. Without profiling support in workers, developers had to rely on external DevTools profiling or indirect measurement: per the explainer, existing worker performance APIs “reveal when tasks are slow, but not why” — they cannot attribute CPU cost to specific JS stacks inside the worker event loop.
The JS Self-Profiling API lets scripts collect low-overhead statistical call-stack samples of their own execution and report them as structured traces. Extending it to dedicated workers gives performance engineers exact CPU attribution for offloaded work without a DevTools/CDP session.
Source: Document Policy in Workers explainer (motivation, quoted); JS Self-Profiling draftexamples
Inside a dedicated worker whose script response carries Document-Policy: js-profiling (flags enabled, Chrome 147):
// worker.js — served with: Document-Policy: js-profiling
// Loaded as a MODULE worker so top-level await below is valid:
// new Worker("/worker.js", { type: "module" })
if (typeof Profiler !== "function") {
postMessage({ unsupported: true }); // trial off / policy missing
} else {
const profiler = new Profiler({
sampleInterval: 10, // ms between samples
maxBufferSize: 10_000, // samples before sampling auto-stops
});
await doHeavyWork();
const trace = await profiler.stop();
// trace is a ProfilerTrace: { resources, frames, stacks, samples }
postMessage({ trace });
}
browser compatibility
Per-version data for the base Profiler interface from BCD api/Profiler.json (verified 2026-09-27); BCD has no worker-support subfeature yet, so that row is interim ChromeStatus data:
| Capability | Chrome | Firefox | Safari |
|---|---|---|---|
Profiler on the main thread (BCD) | 94 | Not shipped (impl bug) | Not shipped |
Profiler in dedicated workers (no BCD subfeature yet; interim) | Developer trial in 147 behind flags (ChromeStatus; no ship milestone set) | No signal — the record’s view notes Firefox “has not shipped JS Self-Profiling; no specific signal on the worker extension” | No signal — same note for Safari on the record |
Feature-detect inside the worker (typeof Profiler === "function") and degrade to coarser instrumentation (User Timing, PerformanceObserver) when absent.
security and privacy
The draft’s Privacy and Security section shields cross-origin script: samples only include functions “defined in a script served with CORS-same-origin” (via the muted-errors property), and browser builtins are included only when invoked from CORS-same-origin script — so the API “does not expose any new insight into the contents or execution characteristics of cross-origin script” beyond what manual instrumentation already allows. Access is additionally opt-in per response through the Document-Policy: js-profiling gate (constructor throws NotAllowedError otherwise), which in a dedicated worker is the worker script’s own policy per the companion reference.
specifications
| Specification | Section |
|---|---|
| JS Self-Profiling API (WICG Draft Community Group Report) | The Profiler interface |
see also
- MDN: Profiler (documents the main-thread API; the worker exposure documented here is not yet covered there, verified 2026-09-27)
- gendn: Document Policy in Dedicated Workers — the policy plumbing this feature is gated on
- chrome-platform-showcase: worker profiling demos (five concepts, route 200)
- ChromeStatus — js-profiling in dedicated workers (5159559872249856)
- blink-dev Intent to Prototype · crbug 482085416