Created
January 2, 2020 20:06
-
-
Save acreskeyMoz/c8249c839ffd5219b767e6fd5c89439b to your computer and use it in GitHub Desktop.
Add resource count and timing to Browsertime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/browserscripts/timings/pageTimings.js b/browserscripts/timings/pageTimings.js | |
index b6e753ce..60b7cc60 100644 | |
--- a/browserscripts/timings/pageTimings.js | |
+++ b/browserscripts/timings/pageTimings.js | |
@@ -1,5 +1,12 @@ | |
(function() { | |
const t = window.performance.getEntriesByType('navigation')[0]; | |
+ | |
+ const resources = performance.getEntriesByType("resource"); | |
+ let resourceDuration = 0; | |
+ for (let i = 0; i < resources.length; i++) { | |
+ resourceDuration += resources[i].duration; | |
+ } | |
+ | |
const d = 0; | |
return { | |
domainLookupTime: Number( | |
@@ -13,6 +20,8 @@ | |
domContentLoadedTime: Number(t.domContentLoadedEventStart.toFixed(d)), | |
pageLoadTime: Number(t.loadEventStart.toFixed(d)), | |
frontEndTime: Number((t.loadEventStart - t.responseEnd).toFixed(d)), | |
- backEndTime: Number(t.responseStart.toFixed(d)) | |
+ backEndTime: Number(t.responseStart.toFixed(d)), | |
+ resourceCount: Number(resources.length), | |
+ resourceDuration: Number(resourceDuration) | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment