如何查看网页性能

window.performance.getEntries();

此方法返回网站所有静态资源(脚本、图片、样式等)的http请求时间数组 。

示例:

var result = [];

window.performance.getEntries().forEach(function (item) {

  result.push({

    'url': item.name,

    'entryType': item.entryType,

    'duration(ms)': item.duration

  });

});

console.log(result);

posted @ 2021-05-11 10:01  marvinLiu  阅读(151)  评论(0)    收藏  举报