Funky on 5

23 June, 2011

Today my copy of Firefox automagically updated itself to 5.0.  This was only slightly annoying because it never asked me (and come to think of it hasn’t asked me any “Do you want to update?” questions for some time).  What did annoy me was that as I went on to browse there were a few sites that now appeared funky or stopped working as I expected.  The culprit?  After a little digging I realized they were looking for exact browser versions :

isFirefox4 = 4 === browserMajorVersion;

… please don’t do that.  If you need to filter functionality on a browser version, at least use a floor for detection:

isFirefox4 = browserMajorVersion >= 4;
isFirefox5 = browserMajorVersion >= 5;

and if necessary for supporting specialized or alternate functionality, a ceiling:

legacyIE = browserMajorVersion >= 6 && browserMajorVersion <= 8;