this post was submitted on 20 Sep 2024
249 points (100.0% liked)

Programmer Humor

418 readers
2 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

alt textCaption

Web dev: What browser is visiting the page?

User agent string:

A screenshot of a browser. The URL bar reads firefox://settings, a button on the URL bar is labelled Netscape, a popup from the button reads: "You're viewing a secure Opera page", and the web page title reads "Chrome settings".

top 16 comments
sorted by: hot top controversial new old
[–] apprehentice@lemmy.enchanted.social 83 points 1 week ago (3 children)

Functionally useless. With the web standardized, we shouldn't need user agents anyway. It would be more beneficial to ask "do you support X, Y, and Z?"

[–] Maestro@fedia.io 25 points 1 week ago (1 children)

It's called feature detection and it goes a long way back, even before Modernizr popularized it.

[–] GammaGames 7 points 1 week ago (2 children)

Popularized? That gets less than 100k downloads a week

[–] dan@upvote.au 14 points 1 week ago* (last edited 1 week ago) (1 children)

Most developers just write their own feature checks (a lot of detections are just a single line of code) or use a library that polyfills the feature if it's missing.

The person you're replying to is right, though. Modernizr popularized this approach. It predates npm, and npm still isn't their main distribution method, so the npm download numbers don't mean anything.

[–] GammaGames 3 points 1 week ago

Neat, thanks for clarifying! I’ve never heard of it

It used to be huge.

[–] dan@upvote.au 15 points 1 week ago

That's exactly what you're supposed to do with the modern web, via feature detection and client hints.

The user agent in Chrome (and I think Firefox too) is "frozen" now, meaning it no longer receives any major updates.

You have to use user agents to fool scummy websites into thinking that you're using chrome or edge.

[–] Tin@lemmy.blahaj.zone 34 points 1 week ago

"yer a jedi, harry" - Gandalf

[–] dan@upvote.au 29 points 1 week ago* (last edited 1 week ago)

User agents are essentially deprecated and are going to become less and less useful over time. The replacement is either client hints or feature detection, depending on what you're using it for.

[–] OpenStars@discuss.online 16 points 1 week ago (1 children)

Is it... (scrolls wheel of browsers) Lynx?

[–] CanadaPlus@lemmy.sdf.org 13 points 1 week ago* (last edited 1 week ago)

I'm still amazed at how usable Lynx is, given the insane premise of the application.

[–] simonced@lemmy.one 11 points 1 week ago

A URL is not an agent string, just saying.

[–] PrimeErective@startrek.website 10 points 1 week ago

A new browser touches the beacon

[–] aaaaace@lemmy.blahaj.zone 9 points 1 week ago

I want a WordPress plugin that refuses to load my site for anyyhing newer than Netscape 3 and pops up a modal "you need to upgrade your browser" pane.

[–] ShellMonkey@lemmy.socdojo.com 1 points 1 week ago

There are some use cases other than web page compatibility. One for me is in dealing with firewall and proxy policy, if the agent is a browser and comes in on specified explicit ports then force authentication, things of that nature.