Nathan's Lucubrations

13 07 2024

Sat, 13 Jul 2024

Use of User-Agent Considered Harmful

Or, "why people who block access to their website based on User-Agent string are incompetent fuckwits" (more in the series "why people who X are incompetent fuckwits" to come later).

I'm not much of a web developer; my skills hew mainly to what the kids these days call "backend" (or possibly the kids from years ago; I remember when "DevOps" was called "a programmer with sysadmin skills". God I'm old). And yeah, I get grumpy about things that I'm not fully aware of (it's a problem I'm working on). Combine this with my lack of subdomain expertise, and IME, IMHO, YMMV, TTWaGoS, IANAL, OMGWTFBBQ (TWAJS).

But here's the thing: the User-Agent is completely fungible - it can easily be changed by the end user. It's not unique, and there are so gorram many of them by now, you're playing whack-a-mole trying to keep up with every one out there.

(And this is before we even get to what amount to plaintext websites not working with text mode browsers because some asshole designer thought they needed to shittify the content that people actually care about with bloated, unnecessary javascript; another rant for another day)

I'm not the only one who has come to this reasoned conclusion - the first result in Google is a Mozilla Developer Network article that says the following:

When considering using the user agent string to detect which browser is being used, your first step is to try to avoid it if possible.

And specifically:

Are you trying to check for the existence of a specific feature? [...] This is the worst reason to use user agent detection because odds are eventually all the other browsers will catch up. In addition, it is not practical to test every one of the less popular browsers and test for those Web features. You should never do user agent sniffing. There is always the alternative of doing feature detection instead.

(bolding mine)

And then they continue on to list code examples of how to properly detect feature support in a browser.

So, to the developers of Slack, who make me change my User-Agent before I even fucking login, fuck you, you incompetent fuckwits.

Also, fix your fucking preferences - I shouldn't have to turn on dark mode every gorram time I login. What is this, the 1990's running off a CD-ROM? No, you don't need a cookie on my machine to record it, just flip a bit in the database entry for my account that you are already storing on your servers.

No web developers were hurt in the making of this blog post, although some should have been. Possibly feelings will be hurt, and valid claims could be made that this post is incendiary, profane, unprofessional, and doesn't help solve the problem, but it's not here to fix things, it's my outlet. If you really want to "git gud noob", try these:

posted at: 19:28 | path: | permanent link to this entry

powered by blosxom