Why exclude browsers one by one?

It may seem better to combine all this code into one section instead of excluding certain browsers using the vagaries of javascript versions.

In the first section on Browser Identification, I hinted at the reason - when the internet gets busy, even the simplest code goes astray. Despite it appearing easier to combine the code, the number of "else if" statements can become very daunting and very confusing. Nesting if statements that deep can cause errors. By splitting the code, I get two main benefits:

  1. Different browsers run different amounts of code.
  2. Newer browsers are more likely to be running faster on faster machines compared to old browsers. So by reducing the amount of code that older, slower browsers have to process, the overall processing time is reduced. I have found this particularly useful in dealing with IE3 related problems.
  3. The code is easier to re-use in other pages where only some browsers may need to be redirected.

Don't take my word for it though. If you want to combine the code, try it and let me know how you get on.