4 ms·
Anyone doing anything with user agents should use ua-parser[0]. Don't even bother trying to do any of this yourself. If ua-parser doesn't exist in your languag
by phamilton 9y ago
Anyone doing anything with user agents should use ua-parser[0]. Don't even bother trying to do any of this yourself.
If ua-parser doesn't exist in your language, just pull the yaml file out of ua-core. That defines the regexes you should use and how they translate to browser versions (and os versions and devices).
[0] https://github.com/ua-parser https://github.com/ua-parser
- whatismybrowser 9y agoShameless plug for the WhatIsMyBrowser.com API: https://developers.whatismybrowser.com/api/ https://developers.whatismybrowser.com/api/ As per modern web dev standards: you should always use feature detection not agent sniffing to handle cross browser issues; however having accurate user agent detection is really handy for trouble shooting customer issues, bot detection, spotting trends etc.
- kccqzy 9y agoAre you encouraging people to do browser sniffing accurately? Aren’t we supposed to discourage such sniffing instead?
- BHSPitMonkey 9y agoYou can still want to parse UAs for other reasons. I used such a library recently in a project where a user is shown their login history, including what OS and browser was used, in a human-readable format (e.g. "Firefox 58 on Linux").
- paulddraper 9y agoIdeally, you would not care at all. You would simply develop HTML 4/5/6 a user has a browser that supports that spec. In reality, browsers have known bugs that last for years, you need to collect stats to figure out support policies, and you need to reproduce customer bugs. Example: old versions of Firefox have an RCE vulnerability if you use third party jsonp apis. If you use these apis but don't block these ff versions, your users will be vulnerable.
- phamilton 9y agoExactly. I had to deal with this due to Chrome 45 blocking flash[0]. While that might not seem like something worth targeting specific browsers, Chrome's implementation of blocking flash was an advertiser's worst nightmare. In order to render the page properly, the page would load with flash enabled on all content. It would then pause the flash runtime on all content not deemed "important". This had the wonderful effect of giving a video ad enough time to start playing a few frames and to fire the impression that results in the advertiser getting billed for showing the ad. This would be flat out fraud on our part (a major video ad exchange), so we had to aggressively avoid allowing flash ads to buy spots from chrome 45 and later. We used ua-parser and everything went very smoothly. [0] https://www.infoq.com/news/2015/08/chrome-45-flash https://www.infoq.com/news/2015/08/chrome-45-flash
- deleted 9y ago[deleted]