Skip to content

Commit 9064727

Browse files
committed
Added performance.now polyfill.
1 parent c0a98c4 commit 9064727

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/polyfills.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,31 @@ if (!window.console)
154154
window.console.log = window.console.assert = function(){};
155155
window.console.warn = window.console.assert = function(){};
156156
}
157+
158+
/**
159+
* performance.now
160+
*/
161+
(function(){
162+
163+
if ("performance" in window == false) {
164+
window.performance = {};
165+
}
166+
167+
Date.now = (Date.now || function () { // thanks IE8
168+
return new Date().getTime();
169+
});
170+
171+
if ("now" in window.performance == false)
172+
{
173+
var nowOffset = Date.now();
174+
175+
if (performance.timing && performance.timing.navigationStart){
176+
nowOffset = performance.timing.navigationStart
177+
}
178+
179+
window.performance.now = function now(){
180+
return Date.now() - nowOffset;
181+
}
182+
}
183+
184+
})();

0 commit comments

Comments
 (0)