Skip to content

Commit 9365a59

Browse files
authored
Get server timing from main response instead of next resource (#2268)
1 parent 8e16a02 commit 9365a59

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed
Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
(function () {
2-
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceServerTiming
3-
const entries = window.performance.getEntriesByType('resource');
4-
if (entries.length > 0 && entries[0].serverTiming) {
5-
const timings = entries[0].serverTiming;
6-
const serverTimings = [];
7-
for (let timing of timings) {
8-
serverTimings.push({
9-
name: timing.name,
10-
duration: timing.duration,
11-
description: timing.description
12-
});
13-
}
14-
return serverTimings;
15-
} else return undefined;
2+
let t = window.performance.getEntriesByType('navigation')[0];
3+
const serverTimings = [];
4+
for (let timing of t.serverTiming) {
5+
serverTimings.push({
6+
name: timing.name,
7+
duration: timing.duration,
8+
description: timing.description
9+
});
10+
}
11+
return serverTimings;
1612
})();

0 commit comments

Comments
 (0)