Skip to content

Instantly share code, notes, and snippets.

@frostney
Created August 15, 2013 13:05
Show Gist options
  • Save frostney/6240668 to your computer and use it in GitHub Desktop.
Save frostney/6240668 to your computer and use it in GitHub Desktop.
Basic shim for getting performance.now() when now function is prefixed. (Prefixes everywhere :) )
var performance = window.performance;
performance.now = performance.now || (function() {
var vendors = ['ms', 'moz', 'webkit', 'o'];
var functionName = '';
for (var i = 0, j = vendors.length; i < j; i++) {
functionName = vendors[i] + 'Now';
if (performance[functionName]) {
return performance[functionName];
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment