About me
Portfolio
BKcore

Blog

Contact

Showing one post from Code

Go back Facebook Twitter Comments

A quick Performance.now() polyfill

By Thibaut Despoulain, posted Aug 22, 2012 in Code
Javascript Tips
(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.

Performance.now() polyfill on GIST

XML/RSS Feed

Categories

3D Code General Orion Photography Random

Tags

Artillery BKcore Cats Class CoffeeScript CSS France HexGL Javascript jQuery OpenGL Orion PHP Release Tips UTBM Video WebGL
(BKcore) Thibaut Despoulain

Home | About me | Portfolio | Blog | Contact | Credits

© 2011 Thibaut Despoulain • Proudly powered by Orion