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

PerformanceEntry: startTime property

· 52CE 我爱测

The read-only **`startTime`** property returns the first DOMHighResTimeStamp recorded for this PerformanceEntry. The meaning of this property depends on the value of this entry's PerformanceEntry.entryType.

Performance API

The read-only startTime property returns the first DOMHighResTimeStamp recorded for this PerformanceEntry. The meaning of this property depends on the value of this entry's PerformanceEntry.entryType.

Value

A DOMHighResTimeStamp representing the first timestamp when the PerformanceEntry was created.

The meaning of this property depends on the value of this performance entry's PerformanceEntry.entryType:

  • container
    • : The value of this entry's PerformanceContainerTiming.paintTime.
  • element
    • : Either the value of this entry's PerformanceElementTiming.renderTime if it is not 0, otherwise the value of this entry's PerformanceElementTiming.loadTime.
  • event
    • : The time the event was created, i.e., the event's timeStamp property.
  • first-input
    • : The time the first input event was created, i.e., that event's timeStamp.
  • largest-contentful-paint
    • : The value of this entry's LargestContentfulPaint.renderTime if it is not 0, otherwise the value of this entry's LargestContentfulPaint.loadTime.
  • layout-shift
    • : The time when the layout shift started.
  • longtask
    • : The time when the task started.
  • mark
    • : The time at which the mark was created by a call to Performance.mark.
  • measure
    • : The time at which the measure was created by a call to Performance.measure.
  • navigation
    • : Always 0.
  • paint
    • : The time when the paint occurred.
  • resource
    • : The time the resource fetch started, including redirects. If there are no HTTP redirects or their timing information is not exposed, this value is equivalent to PerformanceResourceTiming.fetchStart. Otherwise, this value can be earlier than fetchStart.
  • taskattribution
    • : Always 0.
  • visibility-state
    • : The time when the visibility state change occurred.

Examples

Using the startTime property

The following example shows the use of the startTime property which you can log during performance observation.

Note: The performance.mark() method allows you to set your own startTime, and the performance.measure() method allows you to set the start of the measure.

performance.mark("my-mark");
performance.mark("my-other-mark", { startTime: 12.5 });

loginButton.addEventListener("click", (clickEvent) => {
  performance.measure("login-click", { start: clickEvent.timeStamp });
});

function perfObserver(list, observer) {
  list.getEntries().forEach((entry) => {
    if (entry.entryType === "mark") {
      console.log(`${entry.name}'s startTime: ${entry.startTime}`);
    }
    if (entry.entryType === "measure") {
      console.log(`${entry.name}'s duration: ${entry.duration}`);
    }
  });
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["measure", "mark"] });

Specifications

Browser compatibility

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

资料来源与适用范围

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

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

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