alt text

Caption

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”.

  • danA
    link
    fedilink
    arrow-up
    33
    ·
    edit-2
    7 hours 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.

  • apprehentice@lemmy.enchanted.social
    link
    fedilink
    English
    arrow-up
    97
    arrow-down
    2
    ·
    14 hours ago

    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?”

    • elrik@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      2 hours ago

      User agents are useful for checking if the request was made by a (legitimate self-identifying) bot, such as Googlebot.

      It could also be used in some specific scenarios where you control the client and want to easily identify your client traffic in request logs.

      Or maybe you offer a download on your site and you want to reorder your list to highlight the most likely correct binary for the platform in the user agent.

      There are plenty of reasonable uses for user agent that have nothing to do with feature detection.

    • danA
      link
      fedilink
      arrow-up
      15
      ·
      9 hours 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.

        • danA
          link
          fedilink
          arrow-up
          6
          ·
          edit-2
          9 hours ago

          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.

    • Xanthrax@lemmy.world
      link
      fedilink
      arrow-up
      9
      ·
      edit-2
      11 hours ago

      Web UI for touch screens is a lot different than keyboard and mouse. I still switch to desktop most of the time because the mobile site will lack critical info, though. They “have” to streamline the experience for mobile, but I hate it when they fully remove features.

    • Quacksalber@sh.itjust.works
      link
      fedilink
      arrow-up
      19
      arrow-down
      6
      ·
      13 hours ago

      Youtube currently (for weeks now) does not work on Firefox, if you don’t use a Firefox user agent. Google doing sketchy things again.

          • Carighan Maconar@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            1 hour ago

            Both. I use YT on Firefox constantly, and I just explicitly tried again with a swapped user agent, and there’s no issues at all, works perfectly as expected. I saw from your other reply that you use a fairly involved and heavily modifying expansion, not just a user agent switcher.

            If you try to “harden” your FF, always keep in mind that a large portion of that means absolutely breaking things left and right and center. It might work, but always expect it will not. Because it’s just not something anybody would ever test for when creating web pages. So you’re running essentially unknown scenarios. It might be interesting input to the extension-author that this breaks, though. It might be something they think they got working. Of course, it could also be that it’s “Yeah that happens, it’s intentional”. But might as well report it to them.

          • Carighan Maconar@lemmy.world
            link
            fedilink
            arrow-up
            2
            arrow-down
            2
            ·
            edit-2
            3 hours ago

            So you don’t use Firefox, you mess with Firefox. That’s on you then. Devs can’t be held responsible for you intentionally breaking things. Only do what you know works.

      • deltapi@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        8 hours ago

        What’s so insane about it? Web browsers are an evolution of the old gopher protocol. All this stuff has roots in text consoles.