ua-parser-js icon indicating copy to clipboard operation
ua-parser-js copied to clipboard

Can `desktop` be an option for `device.type`?

Open bobsilverberg opened this issue 4 years ago • 2 comments
trafficstars

I notice that device.type can be one of console, mobile, tablet, smarttv, wearable, embedded, but for a desktop browser it just returns undefined. Is there a reason that decision was made? Could device.type return desktop in cases where it is known to be a desktop browser?

bobsilverberg avatar Jun 23 '21 16:06 bobsilverberg

@bobsilverberg Thank you for opening the topic for discussion. As a single-page-app builder I always need to adjust my user interface design for three things:

  • Desktops (all fit-in-bag Laptop/Notebook types and no-carry office-desk Case&Cables types)
  • Tablets
  • Phones

Fine tuning a web app for these 3 main environments is a must. So far I have been using PoeHaH/devicedetector to do that. It works great. It has an isMobile feature that returns true for either tablet or phone which is useful as well in terms of being able to write self-explanatory code.

If ua-parser-js had the same functionality I wouldn't have to include yet another separate library and I could simplify my code.

The-Linguist avatar Aug 02 '21 22:08 The-Linguist

Was discussed here: https://github.com/faisalman/ua-parser-js/issues/182#issuecomment-263115448

ruohola avatar Feb 10 '22 23:02 ruohola