Sunday, August 8, 2010

Detecting IE Platform Preview (and User Agent detection) on Browserscope

On Browserscope we've recently encountered the conundrum of wanting to detect the IE Platform Preview branches and the fact that that information is not in the UA string. Right now, just using the new and improved IE 9 UA string offers no way to detect that someone is using a Platform Preview and also no way to tell which of the 4 previews they are using. Fortunately one can detect this stuff using Javascript, but this forced a rewrite of how we handle UA parsing in Browserscope such that we now can send in overrides for each of the fields we care about for a browser at present - the family, v1, v2, and v3 bits. The code is checked in here in case you have a better way of doing it to share. Thankfully, the IE team is doing such a great job documenting the improvements from release to release that it isn't too painful to get this detection right..

You can also check out this code in action on our UA parser test page too and if for some reason your browser isn't being correctly detected, let us know and we should be able to figure out how to get that right.

All of this though brings me back to the fact that there's really not a great, bleeding-edge accurate, user agent parsing library available today that I'm aware of. The best ones out there at present that I know of are browscap.ini and, but neither of these offer the detection library itself nor are they community maintained and bleeding-edge up to date. There's also WURFL, though it's more about offering a database of capabilities than a universal browser detection tool. Is there something else out there that you know of that's good?

I still have this fantasy of a client library, written to use and cache an ordered list of regexes and patterns for detecting browsers - it would be so cool if this list could be distributed by pubsubhubbub and then any one could host their own, augment the format, or just contribute their changes back to an open source project. Do you know of anyone looking for a fun, meaningful 20% project?

No comments: