Last active
June 16, 2016 16:09
-
-
Save RodrigoSC/be1f0b089aa910d09920 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