Posts tagged ‘javascript’

2013-02-09

User Agent (instead of feature) detection

I previously stated on this blog, and in real life, that there are sites that don’t provide the best experience with my Symbian device just because they are using browser’s User Agent string instead of detecting capabilites.

Just for facts’ sake, the User Agent string of my Nokia Symbian phone’s browser is:

Mozilla/5.0 (Symbian/3; Series60/5.5 Nokia808PureView/113.010.1507; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) 
AppleWebKit/535.1 (KHTML, like Gecko) NokiaBrowser/8.3.2.21 Mobile Safari/535.1

Apple’s iOS5’s is:

Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) 
AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3

and Apple’s iOS6’s is:

Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) 
AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25>

First, the reason I listed al these is so that you can see that the webkit build used on Symbian FP2 is actually a version between iOS5 and iOS6’s webkit version. This actually corresponds to each OS’s release date, so no question marks here.

Now, to the more interesting subject of sites:

There is a common belief, along web programmers since the Netscape 4 vs Internet Explorer (4?) wars, that one should try to code a site with conditions on browser’s features, as opposed to conditionals on browser’s name.

Nowadays, this ‘feature detection’ is what allows you to browse your banks’ site with Chrome, IE, Firefox, Camino, Galeon, lynx – you name it. We have passed waaay ahead from the times when ‘Internet Explorer is required’ was shown on public sites.

However, the same does not apply to mobile site, it seems. It may be the case that the mobile devices’ features cannot be detected in a simple manner, so there sure is some browser User Agent string sniffing around.

As a proof, I happen to have a browser named ‘AnyBrowser’ installed on my Symbian, which’s unique selling point was that it surfs the web under an Android browser User Agent string. Other than that, is a simple QWebkit webview, with a location bar, history, tiling & scrolling and other browser chrome (It was an early 0.4.x version and I don’t find it anymore, so excuse me if you cannot repeat my experiment).

So, browsing the web, with the same webkit component (as shipped by the Qt project), under different names – here are the results:

Picasa Web

On Symbian browser vs Symbian AnyBrowser: by default, you are not even presented with a whimsy 360p image

Scr000034

Scr000033

Facebook login

On Symbian browser vs Symbian AnyBrowser: seems to only be CSS until..

Scr000036

Scr000035

Facebook timeline

On Symbian browser vs Symbian AnyBrowser: Is this actually the same site?

Scr000037

Scr000038

Google Mail

On Symbian browser vs Symbian AnyBrowser: Again, google is by far the worst offender

(Picture got removed for privacy reasons, will update it). Actually, forget about it! AnyBrowser can show Google Maps, while the Symbian stock browser only gets redirected away!

Scr000039scr000055

Engadget

On Symbian browser vs Symbian AnyBrowser: notice the use of custom fonts

Scr000046

Scr000047

Microsoft

On Symbian browser vs Symbian AnyBrowser: search and some asset dimensions are better, but not a whole new site

Scr000050

Scr000051

So really, I cannot stress this more:

All mobile platforms (except Windows) have a webkit build. Differentiating between them when doing a website is like differentiating between Mozilla and Firefox!

The worst offender, is, again, google, followed by facebook. – at least in my examples. Google does not even have APIs for its services (think about dropping exchange support for gmail/calendar, then no API for google plus) or if they have, they are not as popular as they think since nobody does 3rd party apps using google services (and lives on).

Facebook at least has 3rd party applications, so it is useful on Symbian.

update with diclaimer: I am not claiming that those sites work perfectly with just switching the user agent string to an Android one – some testing still needs to be conducted by the site’s owner. But that’s the problem, they don’t do this and preffer to hardcode for a subset of webkit engines which may have – as it’s the case with Apple and Google – some vendor specific features.