Permalink
Browse files

add performance polyfil

  • Loading branch information...
1 parent 2d0a1b5 commit d93461e1f293cd8c89407eeee34c3cc7abb01fe8 @marcuswestin committed Jun 21, 2013
Showing with 27 additions and 0 deletions.
  1. +27 −0 performance.js
View
@@ -0,0 +1,27 @@
+// https://gist.github.com/paulirish/5438650
+
+// relies on Date.now() which has been supported everywhere modern for years.
+// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
+
+(function(){
+ // prepare base perf object
+ if (typeof window.performance === 'undefined') {
+ window.performance = {};
+ }
+
+ if (!window.performance.now){
+
+ var nowOffset = Date.now();
+
+ if (performance.timing && performance.timing){
+ nowOffset = performance.timing.navigationStart
+ }
+
+
+ window.performance.now = function now(){
+ return Date.now() - nowOffset;
+ }
+
+ }
+
+})();

0 comments on commit d93461e

Please sign in to comment.