History of the browser user-agent string
webaim.org
webaim.org
On a related note W3C+Mozilla are trying to document use-cases for UA sniffing: https://etherpad.mozilla.org/uadetection-usecases
The user-agent header is an artifact of history, and should be abolished. I can see no use case for it aside from standards-avoidance.
That's true, but one's platonic idea of the browser does take a backseat to reality.
[0] http://www.nczonline.net/blog/2013/07/02/internet-explorer-1...
It's not at all trustworthy, but in practice it's useful.
For instance, I wrote an IndexedDB-heavy web app. It doesn't work in browsers that don't support IndexedDB. So I do feature detection and if IndexedDB is not supported, I show an error message telling the user that if they want to run the app, they have to use a more modern browser like Firefox, Chrome or IE10.
...except on iDevices, where it is literally impossible to install any browser that supports IndexedDB, despite the fact that it is possible to install something called "Google Chrome" that is not really Google Chrome. So I do user agent detection to display a different message to those users, so as to not give them false hope and confusion.
Admittedly I could invest more time to try to get it working, but iOS represents a relatively small fraction of my users and even a working shim could have problems (IIRC there are serious bugs with WebSQL in iOS 7, not sure if they've been fixed; also, I don't know what this shim approach would do to performance in an IndexedDB-heavy app).
The user agent (UA) string is used by almost every major web brand for one or more of the following purposes:
- To serve different levels of experience to different classes of browsers. This is necessary if you want global coverage i.e. all classes of devices and connectivity. The payload of desktop version of Google is fully 140x bigger than the lightest mobile version, Facebook is similar (check this on http://prism.mobiforge.com). RWD can't do this (many RWD sites simply don't load at all on lower-end phones).
- Serving different experiences to different types of devices e.g. desktop / mobile / TV etc. Don't think this is necessary? Try some of the sites mentioned with a different UA strong and see how it feels.
- Analytics. Google Analytics, Omniture etc. all rely on the UA string to identify types of devices/browser.
- To offer links to the correct app stores for the various mobile OSes
- To make sites faster/lighter for lower end devices. This is important for low-speed connections, faster page loads, metered data plans.
"Based on the commit history, it took several months to create this masterpiece." ...
I don't think that is correct. IE 2 didn't support frames. IE 3 did, but 2 didn't. I remember waiting for IE3 to get more market share so that I could safely use frames.
I can't tell you what feature made them fake the user agent, but it wasn't frame support.
Yeah. Those were the days :-)
There is a silent evidence problem here. Successful use of the user agent string improves the user experience but goes unnoticed; failures are very apparent.
From the article:
"user agent string was a complete mess, and near useless"
vs.
https://etherpad.mozilla.org/uadetection-usecases
His conclusion is a bit like saying "I don't see why I need ABS in this car because I've never skidded since I got it."
I'm actually surprised that Mozilla didn't sue the other browser for using its name in their User-agent browser. This may have secured Mozilla's place as #1.
:(