User Agents and You

December 18th, 2006

I tried to visit a website today that blocked me for using a browser it hadn’t heard of. Why do web designers who are aware enough to know how to access a browser’s user agent only seem to use it to block working browsers from their site? Even Google does it! Let’s set the record straight just in case somebody needs it.

  • GOOD: Noticing a certain older browser doesn’t work with your modern website, so you redirect those who use it so they can upgrade.
  • BAD: Thinking that all browsers except for the few you’re aware of are probably incompatible, so it’s better to block them until they switch to something you are aware of. It could be a security problem if they access your site with an incompatible browser so detecting the user agent is a perfect way to prevent this.
  • GOOD: Relying mostly on CSS and XHTML to ensure that your website will be easy to view in all kinds of browsers (text browsers, older cell-phone browsers for example).
  • BAD: Since your site is table-heavy you change the content based on the user agent (or even possibly the language) to ensure that it can be viewed everywhere. Unless your site is frequently updated it will eventually become outdated and improperly handle newer browsers.
  • GOOD: A specific browser has a bug, so you redirect it when it’s that specific version. That or alter your site so it continues to work while keeping it compatible with other browsers.
  • BAD: A specific browser has a bug, so you block that browser entirely. That or you block all versions starting with above the one with the bug since it will always have that bug.
  • GOOD: Assuming that the user agent can be faked, you develop future-proof ways to detect browser features.
  • BAD: Since browsers are required by law to deliver proper user agents, you use them to detect what features are available.

Basically, don’t change your content based on what browser is accessing it unless that specific version has a problem. Assume future versions will not. Don’t use the user agent in Javascript to detect what features are available. The key word is future-proof, just deliver standardized content and hope for the best. If you really want to do any of the bad things on that list, then at least allow people to bypass it somehow.

Leave a Reply