Forked from paulirish/performance.now()-polyfill.js
Last active
August 24, 2018 10:39
-
-
Save yukulele/5635161 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
// 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 = {} ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this.performance || ( this.performance = {} )
will get you the global, even if that is not window ;)