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 toJSON() method of the TaskAttributionTiming interface is a serializer; it returns a JSON representation of the TaskAttributionTiming object.
toJSON()
None.
A JSON object that is the serialization of the TaskAttributionTiming object.
In this example, calling entry.toJSON() returns a JSON representation of the TaskAttributionTiming object.
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
console.log(entry.toJSON());
});
});
observer.observe({ type: "taskattribution", buffered: true });
This would log a JSON object like so:
{
"name": "unknown",
"entryType": "taskattribution",
"startTime": 0,
"duration": 0,
"containerType": "window",
"containerSrc": "",
"containerId": "",
"containerName": ""
}
To get a JSON string, you can use JSON.stringify(entry) directly; it will call toJSON() automatically.
| Specification |
|---|
| Long Tasks API> # dom-taskattributiontiming-tojson> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
toJSON |
58 | 79 | No | 45 | No | 58 | No | 43 | No | 7.0 | 58 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TaskAttributionTiming/toJSON