-
-
Save asvny/5d10a24d165fca9118ac10d7fdc58a32 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var timing = performance.timing; | |
var requestEntries = performance.getEntries(); | |
var perfData = { | |
PageName: window.location.pathname, | |
JSFilesCount: requestEntries.filter(function(element){return element.name.indexOf('.js')> -1;}).length, | |
CSSFilesCount: requestEntries.filter(function(element){return element.name.indexOf('.css')> -1;}).length, | |
FilesCount: requestEntries.length + 1, | |
TimeToFirstByte: timing.responseStart - timing.navigationStart, | |
TimeToDOMContentLoad: | |
timing.domContentLoadedEventEnd - timing.navigationStart, | |
TimeToFirstPaint: Math.round((window.chrome.loadTimes().firstPaintTime * 1000) - (window.chrome.loadTimes().startLoadTime * 1000)), | |
TimeToLoad: timing.loadEventEnd - timing.navigationStart, | |
IsFirstLoad: requestEntries.filter(function(element){return element.duration == 0;}).length == 0 ? 1 : 0, | |
LoadDuration: timing.loadEventEnd - timing.loadEventStart | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment