running different JavaScript based on browser
<p>Canvas clearing gets vastly different perfomance on different browsers. See <a href="http://jsperf.com/canvas-clearing2" rel="nofollow">http://jsperf.com/canvas-clearing2</a> .</p>

<p>I need to clear a canvas every frame and how I do it has a huge impact on mobile safari vs Desktop safari performance. Desktop Safari likes canvas.width = width but mobile safari prefers canvas.drawRect() .</p>

<p>Is there a way to detect what browser is what an run different JavaScript based on it? I would prefer to do this through JavaScript rather than server side.</p>

<p>Also, I've found that jQuery's $.browser doesn't help because it doesn't distinguish between mobile safari and desktop safari. the navigator object has similar problems.</p>
