PerformanceLongAnimationFrameTiming: toJSON() Methode
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.
Die toJSON()
-Methode der PerformanceLongAnimationFrameTiming
-Schnittstelle ist ein Serializer; sie gibt eine JSON-Darstellung des PerformanceLongAnimationFrameTiming
-Objekts zurück.
Syntax
toJSON()
Parameter
Keine.
Rückgabewert
Ein JSON
-Objekt, das die Serialisierung des PerformanceLongAnimationFrameTiming
-Objekts darstellt.
Beispiele
>Verwendung der toJSON
-Methode
In diesem Beispiel gibt der Aufruf von entry.toJSON()
eine JSON-Darstellung des PerformanceLongAnimationFrameTiming
-Objekts zurück.
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
console.log(entry.toJSON());
});
});
observer.observe({ type: "long-animation-frame", buffered: true });
Dies würde ein Objekt wie folgt protokollieren:
({
blockingDuration: 0,
duration: 60,
entryType: "long-animation-frame",
firstUIEventTimestamp: 11801.099999999627,
name: "long-animation-frame",
renderStart: 11858.800000000745,
scripts: [
{
duration: 45,
entryType: "script",
executionStart: 11803.199999999255,
forcedStyleAndLayoutDuration: 0,
invoker: "DOMWindow.onclick",
invokerType: "event-listener",
name: "script",
pauseDuration: 0,
sourceURL: "https://web.dev/js/index-ffde4443.js",
sourceFunctionName: "myClickHandler",
sourceCharPosition: 17796,
startTime: 11803.199999999255,
window: {
// …Window object…
},
windowAttribution: "self",
},
],
startTime: 11802.400000000373,
styleAndLayoutStart: 11858.800000000745,
});
Um einen JSON-String zu erhalten, können Sie direkt JSON.stringify(entry)
verwenden; es wird toJSON()
automatisch aufrufen.
Spezifikationen
Specification |
---|
Long Animation Frames API> # dom-performancelonganimationframetiming-tojson> |
Browser-Kompatibilität
Loading…