0

I'm using jQuery to do some browser version checks to customize my HTML content.

My first check is simply (pseudocode)

if browser is IE or browser is Firefox
show div1 and hide div2
else
hide div1 and show div2

Simple enough. But in addition if I am showing div2 I want to perform the additional check

if (OS == Mac and browser version less than 4 (firefox 3 or less on Mac)) OR (is IE less than 9)
do foo(alter div2)
else
do fud(leave div2 as is)

My question is should I be doing the 2nd conditional check first, BEFORE I show the div?

Bachalo
  • 6,965
  • 27
  • 95
  • 189
  • 2
    FYI, [browser sniffing is bad](http://stackoverflow.com/questions/1294586/browser-detection-versus-feature-detection) https://www.google.com/?q=browser%20sniffing%20bad – Matt Apr 26 '12 at 12:39
  • I don't think it's likely to make a huge amount of difference, but I'd alter the content of the div before showing it. If it's hidden, altering its contents shouldn't require the browser to redraw the page, so that will only happen once (when you show it), rather than twice (when you show it, then modify its content). – Anthony Grist Apr 26 '12 at 12:47
  • I know in general that feature detection in general is preferred over browser detection but in my case, trying to play full browser flash video with overlayed html content, checking for browser seems like the best way(breaks in chrome and experienced performance issues in Safari) – Bachalo Apr 26 '12 at 13:10
  • Anthony if you want to supply that as an answer I'll accept it – Bachalo Apr 26 '12 at 16:41

0 Answers0