Skip to content

Instantly share code, notes, and snippets.

What would you like to do? polyfill (aka
// @license
// copyright Paul Irish 2015
// is supported everywhere except IE8. For IE8 we use the polyfill
// as Safari 6 doesn't have support for NavigationTiming, we use a timestamp for relative values
// if you want values similar to what you'd get with real, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
if ("performance" in window == false) {
window.performance = {};
} = ( || function () { // thanks IE8
return new Date().getTime();
if ("now" in window.performance == false){
var nowOffset =;
if (performance.timing && performance.timing.navigationStart){
nowOffset = performance.timing.navigationStart
} = function now(){
return - nowOffset;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment