Live data from Hacker News

Chrome phasing out support for User-Agent

infoq.com

21–30 of 329 posts

Re: Chrome phasing out support for User-Agent

#21

I was wondering. Isn't the page rendered on mobile and desktop based on user-agents? How would that work now?

I thought it used Javascript to detect screen size. At least it should react to resize events and if the dimensions are something that align with mobile, it should switch to mobile mode.

In a lot of cases you shouldn't even use Javascript for this, responsive layouts can be built using CSS media queries based on viewport size.

More advanced webapps might occasionally need to do something fancier than that if the mobile vs desktop functionality is (for some reason) substantially different instead of just rearranged.

https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queri...

Re: Chrome phasing out support for User-Agent

#22

I was wondering. Isn't the page rendered on mobile and desktop based on user-agents? How would that work now?

If you want to just change the styling and layout of the page depending on the user's device, then you can use css's media queries[0]. But if you want to serve two totally different pages (one for mobile and another for desktop), then I don't see how it can be done without JS or reading the user agent.

[0] : https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queri...

Re: Chrome phasing out support for User-Agent

#23
post #19

Earlier quoted context omitted.

I use Safari with no plugins. Even Disney World has a broken website for buying tickets for me. The web is breaking because it's gotten way too complex and the fight against trackers is leading to random failures of things that used to work.

The web is breaking because we are reaching the point where developers are able to assume WebKit/Blink and get away with it. It is imperative that technical folk adopt Firefox to hold back the tide.

Safari is WebKit. The trouble probably isn't the engine, it's ITP messing with some analytics thing.

Re: Chrome phasing out support for User-Agent

#24
post #5

I was wondering. Isn't the page rendered on mobile and desktop based on user-agents? How would that work now?

There not phasing out User-Agent strings entirely, they're actually upgrading them: https://github.com/WICG/ua-client-hints It looks like there's more fine grained control in the new version.

Javascript-only is not an upgrade.

Re: Chrome phasing out support for User-Agent

#25

I was wondering. Isn't the page rendered on mobile and desktop based on user-agents? How would that work now?

The typical way this is done these days is by media queries in CSS, so you'd write a rule for styling based on screen width, like @media (max-width: 550 px) { body { background-color: white; } } turns the background white on small screens.

gp is likely asking about how servers decide to redirect to the m.* version instead of the desktop version (or in some cases serve a different mobile version under the same domain), in which case, yes, it’s usually user agent sniffing.

Re: Chrome phasing out support for User-Agent

#26
post #5

Earlier quoted context omitted.

There not phasing out User-Agent strings entirely, they're actually upgrading them: https://github.com/WICG/ua-client-hints It looks like there's more fine grained control in the new version.

Javascript-only is not an upgrade.

UA strings have never been an accurate indication. If you're not using JS, then you probably have no reason to be sniffing the UA string to detect browser features, since most of those features are JS-related anyway.

It's an upgrade for the people who actually need to get an indication of the supported features and APIs of the user's browser. Otherwise, you should be using media queries.

Re: Chrome phasing out support for User-Agent

#27
This is a good idea, and is something I've thought of for a while; the user agent header was a mistake from both a privacy and a UX perspective.

Ideally, web browsers should attempt to treat the content the same no matter what device you are on. There shouldn't be an iOS-web, and a Chrome-web, and a Firefox-web, and an Edge-web; there should just be the web. In which case, a user-agent string that contains the browser and even the OS only encourages differences between browsers. Adding differences to your browser engine shouldn't be considered safe.

Beyond that, the user agent is often a lie to trick servers into not discriminating against certain browsers or OSes. Enough variability is added to the user-agent string that a server can't reliably discriminate, but it still remains useful for some purposes in JavaScript and as a fingerprint for tracking.

Which brings me to privacy. It's not as if there aren't other ways to try and fingerprint a browser, but the user agent is a big mistake for privacy. It'd be one thing if the user-agent just said "Safari" or "Firefox", but there's a lot more information in it beyond that.

If the web should be the same web everywhere, then the privacy trade-off doesn't make much sense.

Re: Chrome phasing out support for User-Agent

#28
post #13

Earlier quoted context omitted.

This last year I've been noticing things breaking on the Internet for me here and there. I'm a Firefox user. This really wasn't the case in most of the past decade. This kinda reminded me of the late 00's. It was quite common that the odd government or enterprise website was IE6 only. All hail the new IE6.

I use Safari with no plugins. Even Disney World has a broken website for buying tickets for me. The web is breaking because it's gotten way too complex and the fight against trackers is leading to random failures of things that used to work.

To be fair, you are using a browser that makes it impossible to test in unless you happen to have a current mac.

Re: Chrome phasing out support for User-Agent

#29
post #26

Earlier quoted context omitted.

Javascript-only is not an upgrade.

UA strings have never been an accurate indication. If you're not using JS, then you probably have no reason to be sniffing the UA string to detect browser features, since most of those features are JS-related anyway. It's an upgrade for the people who actually need to get an indication of the supported features and APIs of the user's browser. Otherwise, you should be using media queries.

One exception: you might want to user sniff IE and serve a completely different version due to all the CSS problems. (I know you can use IE-only comments too, but I’ve been in the situation where making a modern version simultaneously IE9-compatible was just too frigging maddening.)

Re: Chrome phasing out support for User-Agent

#30
post #15

As usual, this will fuck up the users, and not the techy nerds making such decisions, but the average joe because things on the internet will be broken for them.

How will things be broken? Google is not removing the user agent, they're just freezing it. So all sites that currently depend on the user agent will continue to do just fine. New sites can use client hints instead, which are a much more effective replacement for user agent sniffing. This solution very specifically places the burden on "techy nerds" and not users, so I'm not sure where you're coming from.

Right, using user agent on the client side has been unsalvageably broken for a long time. Other things, like checking the existence of window.safari or window.chrome are more reliable.

For the server side, I’m not too aware of too many cases it’s useful other than analytics, and there is too much info leakage and fingerprinting happening anyway.

So killing user agent doesn’t really seem user-hostile, save for the fact that the company doing it has near monopoly market share and doesn’t need to provide a user agent, as it’s assumed that everyone is writing code to run on Google’s browser. In that sense it’s a flex.

Post reply on HN