大网数据广告活动
Web 标准与前端开发

PerformanceScriptTiming

· 52CE 我爱测

The **`PerformanceScriptTiming`** interface is specified in the Long Animation Frames API and provides metrics on individual scripts that contribute to long animation frames (LoAFs).

Performance API

The PerformanceScriptTiming interface is specified in the Long Animation Frames API and provides metrics on individual scripts that contribute to long animation frames (LoAFs).

PerformanceScriptTiming inherits from PerformanceEntry.

Instance properties

This interface extends the following PerformanceEntry properties for long animation frame performance entries:

  • PerformanceEntry.duration
    • : Returns a DOMHighResTimeStamp representing the elapsed time in milliseconds between the start and end of the script's execution.
  • PerformanceEntry.entryType
    • : Returns the entry type, which is always "script".
  • PerformanceEntry.name
    • : Returns the entry name, which is always "script".
  • PerformanceEntry.startTime
    • : Returns a DOMHighResTimeStamp representing the time when the script execution started, in milliseconds.

This interface also supports the following properties:

  • PerformanceScriptTiming.executionStart
    • : Returns a DOMHighResTimeStamp indicating the time when the script compilation finished and execution started.
  • PerformanceScriptTiming.forcedStyleAndLayoutDuration
    • : Returns a DOMHighResTimeStamp indicating the total time spent, in milliseconds, by the script processing forced layout/style. See Avoid layout thrashing to understand what causes this.
  • PerformanceScriptTiming.invoker
    • : Returns a string value indicating the identity of the feature that, when invoked, ran the script.
  • PerformanceScriptTiming.invokerType
    • : Returns a string value indicating the type of feature that, when invoked, ran the script.
  • PerformanceScriptTiming.pauseDuration
    • : Returns a DOMHighResTimeStamp indicating the total time, in milliseconds, spent by the script on "pausing" synchronous operations (for example, Window.alert() calls or synchronous XMLHttpRequests).
  • PerformanceScriptTiming.sourceCharPosition
    • : Returns a number representing the script character position of the script feature that contributed to the LoAF.
  • PerformanceScriptTiming.sourceFunctionName
    • : Returns a string representing the name of the function that contributed to the LoAF.
  • PerformanceScriptTiming.sourceURL
    • : Returns a string representing the URL of the script.
  • PerformanceScriptTiming.window
    • : Returns a reference to a Window object representing the window of the container (i.e., either the top-level document or an iframe) in which the LoAF-causing script was executed.
  • PerformanceScriptTiming.windowAttribution
    • : Returns an enumerated value describing the relationship of the container (i.e., either the top-level document or an iframe) in which the LoAF-causing script was executed, relative to the window running the current document.

Instance methods

  • PerformanceScriptTiming.toJSON()
    • : Returns a JSON-serializable plain object representing the PerformanceScriptTiming object. Automatically called by JSON.stringify().

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 PerformanceScriptTiming interface (instances of which are accessed via the PerformanceLongAnimationFrameTiming.scripts property) provides the following granular set of information on individual scripts that contribute to LoAFs, allowing developers to narrow down their root causes:

  • A detailed set of timestamps for each script.
  • The identity and type of the invoker, i.e., the feature that, when invoked, ran the script.
  • Detailed information on each script source file, including the URL, and the function name and character position that contributed to the LoAF.

Examples

See Long animation frame timing for examples related to the Long Animation Frames API.

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。