Turning up our noses at browser sniffing


Did you notice it? Well if you’re an Opera user you might. As of last week, if you go to Bing using Opera, you’ll get to see the HTML5 background video in all its glory.

Now, let’s be clear, it’s not as if Opera couldn’t play the video before. It just never got the chance.

You see Bing used browser sniffing to determine what it thought visitors’ browsers could and could not deal with. Browser Sniffing is, to my mind, a relic that should have been put to rest years ago. But, like a bad smell, it’s just hung around.

The problem with browser sniffing is – and I believe this is the technical term – it’s just a bit pants. With so many browsers and so many user agent strings (not to mention browsers pretending to be other browsers) you simply can’t guarantee the right result.

This means you’ll tend to exclude at least a portion of your audience (probably unnecessarily as most browsers deal with most code just fine – as in the Bing example with Opera).

The solution to Browser Sniffing? Feature detection… Rather than guessing at what the browser is capable of, you use JavaScript to test the browser. In general this is far more accurate and delivers far better results.

To learn more about feature detection – and particularly how to write a feature detection tests in JavaScript – check out my earlier post. And to see a demo in action, take a look at the tutorial video I created with Ubelly detailing how Sky News used feature detection in a proof of concept project I worked on last year.

Comments (11)

  1. BS-Harou says:

    Thank you!

    Sincerely, Opera user :)

  2. Mno says:

    Another thank you from an Opera user.

  3. Lars says:

    A thank you from another Opera user.

  4. Abhilash says:

    Why does the article url have 2012/02/08 ? :)

    Did not work for me. I tried with Bing US as well

  5. thebeebs says:

    @Abhilash you came to the site using a short URL that I made when I thought I was going to publish the article on Wednesday (the 8th of Febuary). You will notice that you can use the the URL 2012/02/08 or 2012/02/06. I decided to publish the article early, I forgot to change the short URL.

    As for Bing… they don't publish a video background every day. As I write this there is a video of the Northern lights Vee Lake Canada which was published 6 days ago. You can flip to previous days using the arrows on the bottom right of the picture.

  6. Mike says:

    Doing web design for a living, I am in total agreement with the sentiment of this post. As an Opera user, I always appreciate when sites don't discriminate.

  7. Andrew says:

    Thank you!

  8. Diego says:

    A thank you from another Opera user. o/

  9. greench says:

    One more thank you for one another Opera user :)

  10. Nick says:

    While I'm in agreement with some of what this post says, I have to say that I see nothing wrong with the occasional browser sniff depending on what you're trying to do.

    I often use it (with no problems – yet) to detect if the user is on an iPhone or iPad – usually because the page they are visiting requires them to upload something, which you can't do on both these devices as they have no file structure as such, and, as far as I know there is no way to use browser detection to get through this.

  11. thebeebs says:

    @nick totally agree. As with everything there are always exeptions.