"To do this, there are heavy tools out there, like WURFL, DeviceAtlas or lighter ones like Browser Gem, that read the user agent string and start from there."
All this time we were told 'browser detection is bad', yet... the only real way to give optimal experiences for mobile is... 'browser detection'.
In theory, browser detection is bad, because we should rely on detecting whether JavaScript functions exist or not, etc.
In practice, browser detection is usually necessary, no way around it. Thinking about writing HTML5 audio functionality? Guess what, every browser implements it differently, and you just have to detect the browser so you know whether to respond to the 'ended' event or the 'pause' event, or whether calling load() before playing is necessary, or will crash a certain mobile browser. (I could go on about 100 more things.)
So, in an interview, always explain that browser detection is bad. Once you're hired, you'll find that most reasonably complex sites use it out of necessity.
Yes! When I saw that I nearly closed the page then and there. Frankly, anyone advocating this has likely never tried to do it. In my experience the data goes out of date almost instantly anyway, the technique is not fully reliable and if you start going down this rabbit hole you realize there are so many varied devices to take into consideration that it becomes pointless anyway.
This also completely contradicts what I thought was the entire point of the article.
I hear you, but I think it's a mistake to take things like "browser detection is bad" as inviolable axioms. These sorts of best practices are results-oriented, so when we want different results, we have to reevaluate them. I am not necessarily saying browser sniffing is now an awesome idea, though.
I was under the impression that tracking users by uniquely identifying them by their browser was bad, not merely detecting their browser and its properties? Or did I miss something?
No, you didn't miss anything. It's just that... for years, we got "browser detection is bad" thrown at us. I realize I'm conflating things a bit, but personally I never did anything like "if useragent=='mozilla' redirect to 'we only support ie.html'", although many did (back in the day). "browser detection" got a bad rap, and had been "out of favor" for a long time (or appeared to be). Yet... the only way to avoid sending down a 400k of HTML to a mobile device is to... detect the device and send down smaller amounts of stuff.
It's "bad" because its very difficult to plan for all of the extreme edge cases found on the net. If UA Sniffing was infalliable, there would be a lot more of it.
Enabling/disabling features by user agent tends to break over time. Browsers implement features, but your user agent sniffing keeps them disabled.
Or as I get a lot, you use a non-standard but standards-compliant browser and then have to spoof the user agent of one of the major browsers to persuade the site to actually use the features your browser has.
All this time we were told 'browser detection is bad', yet... the only real way to give optimal experiences for mobile is... 'browser detection'.