Live data from Hacker News

UA Gotta Be Kidding

bkardell.com

91–93 of 93 posts

Re: UA Gotta Be Kidding

#91
post #32

I think it's interesting to note that the majority of web developers for at least the last 10 years have realised that the User Agent is a very flaky way to determine capability. It is almost universally ignored now (with a few enterprise-level exceptions) So the usual solution is feature detection, where the javascript and/or CSS learns the true capabilities of the browser, and switches features on and off according…

> It is almost universally ignored now I wish. Once in a while I come up to sites that present content based on UA (e.g switching UAs produces a different layout). In all cases things work, but the UA pile of lies can make it a subpar experience on this or that device with this or that browser.

Oh, it definitely happens. Especially when you have certain multinational corporations with their own browser and far too much market share who claim their online office suite couldn't possibly work perfectly on 's browser because it isn't as shiny as their browser.

The only other exception I've seen recently is because of genuinely lacking features e.g. WebMidi, or where a really small outfit just doesn't have the time to ensure 100% compatibility with every browser yet, so puts it out there with heavy warnings.

But IME, it is vanishingly rare to find a website that says "Nope, can't do this with firefox" and flat-out refuse to serve you without a very good reason, and when they do, they're idiots if they use the highly-spoofable UA to do that check.

(But I would love to see counter-examples - as I say, I'm sure they exist, but outside the corporate world, I haven't seen it in a while)

Re: UA Gotta Be Kidding

#92

I think it's interesting to note that the majority of web developers for at least the last 10 years have realised that the User Agent is a very flaky way to determine capability. It is almost universally ignored now (with a few enterprise-level exceptions) So the usual solution is feature detection, where the javascript and/or CSS learns the true capabilities of the browser, and switches features on and off according…

if browsers would stop lying about dpi, we wouldn't need to guess trough UA wheter something is a low res desktop, a high resolution small monitor or something in between (and let's not start talking about browser windows that aren't fullscreen). once we could at least use the availability of touch features to guide between the cases, but now that one started lying as well. we parse user agent not because we like to…

Yeah. To some extent, that's outside the browser's hands - if the system doesn't know what the "real world pixel size" is (insert obligatory "of course I know pixels don't exist" disclaimer here) then there's no way to pass that information on to the browser.

Complete side note, I'm shocked at how terribly Linux is still doing at the whole hi-dpi vs lo-dpi vs everything in between.

But yes, generally speaking the gold standard is CSS rems - it presumes that a user has somewhat configured their machine comfortably, mind. But if you use that text size as a relative measure for all the text on their screens, you can scale your interface elements knowing that if 1rem is a good readable size for a letter, all headings etc should be bigger, no interactive element should ever be smaller than 1rem (and should probably be a fair bit bigger on mobile devices), you can define margins around this measure too.

It isn't perfect, but it'll beat UA most of the time. You'll stop worrying about the definition of high res and low res, and instead focus on the comfort of the individual - which might be a bespectacled octogenarian or an impoverished student on the same system.

Re: UA Gotta Be Kidding

#93
post #2

For some reason, I always enjoy reading about UA history. There’s rarely anything new (for me, partially because I lived through some of those earlier changes), but I’m still entertained. This had a new tidbit in the final section, though: They are working on a new XR browser [0] and history is repeating itself. Only tangentially related, but when I checked the mobile browser stats for Germany, I found out about Inst…

You might be interested in this IMC 2017 paper: https://conferences.sigcomm.org/imc/2017/papers/imc17-final2... There was a crazy "android anomaly of 2015" that nobody else seems to have noticed. The Microsoft XML file with domain-UA pairs is among the most insane ideas I have ever seen. Both are described in this paper.

Hah, the android anomaly was fun, despite probably being benign :D The Microsoft UA thing wasn’t actually news to me, they’ve always had crazy hacks like that.
Post reply on HN