EN
JavaScript - how to measure website load / speed time?
2 points
xxxxxxxxxx
1
window.performance.getEntriesByType("navigation")
Example output:
xxxxxxxxxx
1
PerformanceNavigationTiming
2
connectEnd: 229.59999999403954
3
connectStart: 229.59999999403954
4
decodedBodySize: 136266
5
domComplete: 1087.8999999761581
6
domContentLoadedEventEnd: 1048.5999999940395
7
domContentLoadedEventStart: 1047.8999999761581
8
domInteractive: 1047.699999988079
9
domainLookupEnd: 229.59999999403954
10
domainLookupStart: 229.59999999403954
11
duration: 1089.199999988079
12
encodedBodySize: 27486
13
entryType: "navigation"
14
fetchStart: 229.59999999403954
15
initiatorType: "navigation"
16
loadEventEnd: 1089.199999988079
17
loadEventStart: 1087.8999999761581
18
name: "https://dirask.com/posts/Node-js-PostgreSQL-Select-last-row-1AqP01"
19
nextHopProtocol: "h2"
20
redirectCount: 2
21
redirectEnd: 229.59999999403954
22
redirectStart: 3.5
23
requestStart: 232.39999997615814
24
responseEnd: 343.59999999403954
25
responseStart: 325.5
26
secureConnectionStart: 229.59999999403954
27
serverTiming: [PerformanceServerTiming]
28
startTime: 0
29
transferSize: 28777
30
type: "navigate"
31
unloadEventEnd: 332.19999998807907
32
unloadEventStart: 332
33
workerStart: 0
Measure all resources loaded on the webpage
xxxxxxxxxx
1
window.performance.getEntries()
Example output:
xxxxxxxxxx
1
0: PerformanceNavigationTiming {unloadEventStart: 332, unloadEventEnd: 332.19999998807907, domInteractive: 1047.699999988079, domContentLoadedEventStart: 1047.8999999761581, domContentLoadedEventEnd: 1048.5999999940395, …}
2
1: PerformanceResourceTiming {initiatorType: "link", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
3
2: PerformanceResourceTiming {initiatorType: "script", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
4
3: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
5
4: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
6
5: PerformanceResourceTiming {initiatorType: "script", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
7
6: PerformancePaintTiming {name: "first-paint", entryType: "paint", startTime: 648.5999999940395, duration: 0}
8
7: PerformancePaintTiming {name: "first-contentful-paint", entryType: "paint", startTime: 648.5999999940395, duration: 0}
9
8: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
10
9: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
11
10: PerformanceResourceTiming {initiatorType: "xmlhttprequest", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
12
11: PerformanceResourceTiming {initiatorType: "xmlhttprequest", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
13
12: PerformanceResourceTiming {initiatorType: "xmlhttprequest", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
14
13: PerformanceResourceTiming {initiatorType: "xmlhttprequest", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
15
14: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
16
15: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
17
16: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
18
17: PerformanceResourceTiming {initiatorType: "img", nextHopProtocol: "h2", workerStart: 0, redirectStart: 0, redirectEnd: 0, …}
19
18: PerformanceEventTiming {processingStart: 1342.3999999761581, processingEnd: 1344.199999988079, cancelable: true, target: body, name: "keydown", …}
20
length: 19
xxxxxxxxxx
1
window.performance
Example output:
xxxxxxxxxx
1
eventCounts: EventCounts
2
size: 36
3
__proto__: EventCounts
4
memory: MemoryInfo
5
jsHeapSizeLimit: 4294705152
6
totalJSHeapSize: 21881456
7
usedJSHeapSize: 16685568
8
__proto__: MemoryInfo
9
navigation: PerformanceNavigation
10
redirectCount: 2
11
type: 0
12
__proto__: PerformanceNavigation
13
onresourcetimingbufferfull: null
14
timeOrigin: 1624304452160.4
15
timing: PerformanceTiming
16
connectEnd: 1624304452389
17
connectStart: 1624304452389
18
domComplete: 1624304453248
19
domContentLoadedEventEnd: 1624304453208
20
domContentLoadedEventStart: 1624304453208
21
domInteractive: 1624304453208
22
domLoading: 1624304452501
23
domainLookupEnd: 1624304452389
24
domainLookupStart: 1624304452389
25
fetchStart: 1624304452389
26
loadEventEnd: 1624304453249
27
loadEventStart: 1624304453248
28
navigationStart: 1624304452160
29
redirectEnd: 1624304452389
30
redirectStart: 1624304452163
31
requestStart: 1624304452392
32
responseEnd: 1624304452503
33
responseStart: 1624304452485
34
secureConnectionStart: 0
35
unloadEventEnd: 1624304452492
36
unloadEventStart: 1624304452492
37
__proto__: PerformanceTiming
38
__proto__: Performance