2. Because you're not going to update your detection every time a new version comes out, meaning that new browsers that support the features you need are still going to get served the wrong version of your site.
3. Because there are more browsers than you can count.
4. Because for non-syntax related features, feature detection on the client is usually pretty simple.
5. Because the UA is trivial to spoof.
It's just another method of dispatch instead of runtime checks inside JS. At worst you put the runtime check in the "I don't know what you are" variant and let them run slower.
For 5: If the browser's lying, you're morally off the hook. The user's configured their browser to lie, and gets what they deserve.
For point 4, fair enough. Go for that when you can.
It doesn't have to be trivial to be worth doing.
> However, it's not recommended to use this library as browser detection since the result may not accurate than using feature detection.
Although, it's not very good in Chrome either :)
Yes, very much so. Especially on mobile, where UA-sniffing is rife.
Here's a very much non-exhaustive sample:
https://bugzilla.mozilla.org/show_bug.cgi?id=1047854
https://bugzilla.mozilla.org/show_bug.cgi?id=975444
https://bugzilla.mozilla.org/show_bug.cgi?id=1322001
https://bugzilla.mozilla.org/show_bug.cgi?id=958575
https://bugzilla.mozilla.org/show_bug.cgi?id=1020740
https://bugzilla.mozilla.org/show_bug.cgi?id=1232656
https://bugzilla.mozilla.org/show_bug.cgi?id=1377499
https://bugzilla.mozilla.org/show_bug.cgi?id=1393109
(funny what percentage of those are google.com sites....)
If your app holds a mini "caniuse.com" UA-feature mapping, you have to keep it up to date infinitely forward in time, or new browsers won't work (think Brave/etc)
Better to detect features directly, and reward anyone who implements them, rather than just hardcode the present incumbents.
Having browsers identify themselves by the features they support would have been nice, but also very complicated, and it's not where we are now.
Or the "Browse the web faster and more securely, try (Chrome|Edge)" crap?