The entryType  返回一个代表performance metric 类型的DOMString , 例如被performance.mark("begin") 所创建的entry 的entryType 就是 "mark". 此属性只读.


var type = entry.entryType;


返回值取决于  PerformanceEntry 对象的subtype, entryType的取值会影响 属性, 具体如下表所示. 

Value Subtype Type of name property Description of name property
frame, navigation PerformanceFrameTiming, PerformanceNavigationTiming URL The document's address.
resource PerformanceResourceTiming URL The resolved URL of the requested resource. This value doesn't change even if the request is redirected.
mark PerformanceMark DOMString The name used when the mark was created by calling performance.mark().
measure PerformanceMeasure DOMString name used when the measure was created by calling performance.measure().
paint PerformancePaintTiming DOMString Either 'first-paint' or 'first-contentful-paint'.



下面的代码说明了  entryType 属性的用法.

function run_PerformanceEntry() {

  // check for feature support before continuing
  if (performance.mark === undefined) {
    console.log("performance.mark not supported");

  // Create a performance entry named "begin" via the mark() method
  // Check the entryType of all the "begin" entries
  var entriesNamedBegin = performance.getEntriesByName("begin");
  //    Array [ PerformanceMark ]
  //    PerformanceMark { name: "begin", entryType: "mark", startTime: 94661370.14, duration: 0 }
  //    "mark"
  //    "begin"
  for (var i=0; i < entriesNamedBegin.length; i++) {
      var typeOfEntry = entriesNamedBegin[i].entryType;
      console.log("Entry is type: " + typeOfEntry);



Specification Status Comment
Performance Timeline Level 2
Candidate Recommendation  
Performance Timeline
Recommendation Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support. (Yes) (Yes) (Yes) (Yes) (Yes) 未实现
Avaialable on workers 62 ? ? ? 49 ?
Feature Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support. (Yes) (Yes) (Yes) 25.0 (25.0) 1.2 (25.0) 10.0 (Yes) 未实现
Avaialable on workers 62 62 ? ? ? ? 49 ?


此页面的贡献者: ihgazni2
最后编辑者: ihgazni2,