Devs: UA sniffing is a bad idea
Neowin has reported changes to the User Agent (UA) string found in IE11 after a leak of Windows Blue, the next iteration of Windows 8.
The site concluded Microsoft’s browser would “appear as Firefox to avoid legacy IE CSS,” through the inclusion of ‘like Gecko’ in the UA string. The site added that the UA string has also dropped 'MSIE' in favour of 'IE', which it argued could potentially cause issues with sites reliant on UA strings to detect browsers and amend sites accordingly.
“Relying on a UA string should be your last port of call, and then only if it is absolutely necessary,” blasted experience designer Aral Balkan about any suggestion the change could adversely affect websites. “Design from the content out, progressively enhance and test for features,” he added.
Easy Designs founder Aaron Gustafson added that the industry should take a ‘wait and see’ approach before leaping to conclusions: “For all we know, the IE devs decided to opt for a temporary break from the old UA string in order to be able to accurately test IE11’s compatibility with sites that make use of poorly-implemented UA sniffing.”
Like Balkan, Gustafson said such UA sniffing was a bad idea for determining standards support, because UA strings are too easily spoofed. He admitted there were rare exceptions: “Looking for simple strings like 'MSIE' is worthless, but looking for a specific version of WebKit because you know that version has a specific bug in it can sometimes be the only way to accurately adapt your website to the browser.” However, he argued that feature-testing is generally a better bet.
Author and web standards expert Eric Meyer told .net that Neowin’s original premise was also inaccurate, because what’s reportedly happening with IE11 isn’t anything new: “Assuming they preserve that into the final release, so what? WebKit, as Konqueror did before it, has always included ‘like Gecko’ in its UA string. Similarly, the word ‘Mozilla’ has appeared in just about every major browser's UA string since forever, even though it should only apply to Firefox and its cousins. Opera included 'Gecko' in its UA string, though not ‘like’, and also included ‘MSIE’ in its Windows releases!”
Meyer said that IE isn’t pretending to be anything other than what it is and it’s “certainly not lurking as Gecko,” merely “making changes to its UA string”. He added anyone making the assumption ‘like Gecko’ essentially meant ‘not IE’ was being “short-sighted and frankly foolish”.
Still, like Balkan and Gustafson, Meyer agreed the incident was a useful reminder that UA sniffing is a bad idea: “If sites are still dependent on UA string parsing for their behaviour, they're a decade behind the times. It was never a good idea, it's been widely known to be a very not-good idea for years upon years now, and this just serves to further illustrate how very, very not-good an idea it's always been!”
Microsoft did not return .net's request for comment.
Image credit: Neowin.