Last active
December 20, 2015 05:59
-
-
Save overbalance/6082377 to your computer and use it in GitHub Desktop.
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
// relies on Date.now() which has been supported everywhere modern for years. | |
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values | |
(function(window) { | |
// prepare base perf object | |
if ("performance" in window) {} else { | |
window.performance = {}; | |
} | |
if ("now" in window.performance) {} else { | |
var nowOffset = Date.now(); | |
if ("timing" in window.performance && "navigationStart" in window.performance.timing) { | |
nowOffset = window.performance.timing.navigationStart; | |
} | |
window.performance.now = function() { | |
return Date.now() - nowOffset; | |
}; | |
} | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment