Performance API
The PerformanceLongAnimationFrameTiming interface is specified in the Long Animation Frames API and provides metrics on long animation frames (LoAFs) that occupy rendering and block other tasks from being executed.
PerformanceLongAnimationFrameTiming inherits from PerformanceEntry.
Instance properties
This interface directly defines the following properties:
- PerformanceLongAnimationFrameTiming.blockingDuration
- : Returns a DOMHighResTimeStamp indicating the total time in milliseconds that the main thread was blocked from responding to high priority tasks, such as user input. This is calculated by taking all the long tasks within the LoAF that have a
durationof more than50ms, subtracting50msfrom each, adding the rendering time to the longest task time, and summing the results.
- : Returns a DOMHighResTimeStamp indicating the total time in milliseconds that the main thread was blocked from responding to high priority tasks, such as user input. This is calculated by taking all the long tasks within the LoAF that have a
- PerformanceLongAnimationFrameTiming.firstUIEventTimestamp
- : Returns a DOMHighResTimeStamp indicating the time of the first UI event — such as a mouse or keyboard event — to be queued during the current animation frame.
- PerformanceLongAnimationFrameTiming.paintTime
- : Returns the DOMHighResTimeStamp when the rendering phase ended and the animation frame started.
- PerformanceLongAnimationFrameTiming.presentationTime
- : Returns the DOMHighResTimeStamp when the UI update was actually drawn on the screen.
- PerformanceLongAnimationFrameTiming.renderStart
- : Returns a DOMHighResTimeStamp indicating the start time of the rendering cycle, which includes Window.requestAnimationFrame() callbacks, style and layout calculation, ResizeObserver callbacks, and IntersectionObserver callbacks.
- PerformanceLongAnimationFrameTiming.scripts
- : Returns an array of PerformanceScriptTiming instances.
- PerformanceLongAnimationFrameTiming.styleAndLayoutStart
- : Returns a DOMHighResTimeStamp indicating the beginning of the time period spent in style and layout calculations for the current animation frame.
It also extends the following PerformanceEntry properties, qualifying and constraining them as described:
- PerformanceEntry.duration
- : Returns a DOMHighResTimeStamp representing the time taken in milliseconds to process the LoAF in its entirety.
- PerformanceEntry.entryType
- : Returns the entry type, which is always
"long-animation-frame".
- : Returns the entry type, which is always
- PerformanceEntry.name
- : Returns the entry name, which is always
"long-animation-frame".
- : Returns the entry name, which is always
- PerformanceEntry.startTime
- : Returns a DOMHighResTimeStamp representing the time when the animation frame started.
Instance methods
- PerformanceLongAnimationFrameTiming.toJSON()
- : Returns a JSON-serializable plain object representing the
PerformanceLongAnimationFrameTimingobject. Automatically called by JSON.stringify().
- : Returns a JSON-serializable plain object representing the
Description
Long animation frames (LoAFs) are rendering updates that are delayed beyond 50ms. LoAFs can result in slow user interface (UI) updates, making controls appear unresponsive and causing janky (non-smooth) animated effects and scrolling. This often leads to user frustration.
The PerformanceLongAnimationFrameTiming interface provides the following granular set of information on LoAFs, allowing developers to narrow down their root causes:
- A detailed set of timestamps for each LoAF.
- Detailed information on each script that contributed to creating the LoAF, via the PerformanceLongAnimationFrameTiming.scripts property. This returns an array of PerformanceScriptTiming objects, one for each script.
Examples
See Long animation frame timing for examples related to the Long Animation Frames API.
Specifications
Browser compatibility
See also
- Long animation frame timing
- PerformanceScriptTiming
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
