Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yukulele/5635161 to your computer and use it in GitHub Desktop.
Save yukulele/5635161 to your computer and use it in GitHub Desktop.
// if Navigation Timing is not supported, fallback to Date.naw() called on start (sufficient in many cases)
// Date.now is also polyfilled
(function(p){
if(!Date.now)
Date.now = function(){return +new Date};
if (!p.now){
var start = (p.timing && p.timing.navigationStart) || Date.now();
p.now = function now(){
return Date.now() - start;
};
}
})( this.performance || ( this.performance = {} ) );
@wadeharrell
Copy link

this.performance || ( this.performance = {} )
will get you the global, even if that is not window ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment