wx:qy1037428670
1 window.performance

控制台打印可以看出performance属性是记录当前页面性能相关的API,那么一般的性能优化都是从网络请求的整个链路来做优化
2 performance.navigation(删除:使用需考虑浏览器支持情况)

{
redirectCount:0,// 代表重定向的次数
type:0,
}
performance.navigation 这个API主要记录路由的跳转和切换,redirectCount记录的是重定向的次数
type值有0,1,2,255;其中
0:通过点击链接,提交表单,js脚本修改url,以及直接在浏览器地址栏输入url,这些情况,type值为0
1:页面刷新或者利用js调用Location.load(),这两种情况type值为1
2:通过浏览器前进和后退进入的页面,type值为2
255:任何其他方式
3 performance.timing (删除:使用需考虑浏览器支持情况)
目前是使用最多的关于页面性能相关的API
image.png
timing属性返回一个PerformanceTiming对象,包含延时相关的性能信息,navigation&redirect&fetch&request&response
4 Performance.getEntries()
未完待续
网友评论