A quick Performance.now() polyfill
By Thibaut Despoulain, posted Aug 22, 2012 in Code
(function(w){ var perfNow; var perfNowNames = ['now', 'webkitNow', 'msNow', 'mozNow']; if(!!w['performance']) for(var i = 0; i < perfNowNames.length; ++i) { var n = perfNowNames[i]; if(!!w['performance'][n]) { perfNow = function(){return w['performance'][n]()}; break; } } if(!perfNow) { perfNow = Date.now; } w.perfNow = perfNow; })(window); // Usage console.log(window.perfNow());
Just a quick performance.now() polyfill since the ones I found were producing "Illegal invocation" errors. This polyfill wraps the performance call inside a function to avoid this.