|
|
|
|
|
by err4nt
3987 days ago
|
|
Sniffing User-Agent has been poor practice since 2011 , in favour of feature detection using a library like Modernizr. I used to advocate using something like Modernizr and then writing your code against the results, but now I think an even more straightforward approach is to just do the feature detection you wish to use directly in your code. No sense in loading in a library and testing for things you don't need, still only to have those tests totally decoupled from the parts of your codebase that depend on the feature detection. It makes more sense to do only the feature detection you need right in your codebase adjacent to the code which relies on the results. |
|
I'm old enough to remember it was much earlier than that. In the early '00s there were already calls to do feature detection; jQuery was released in 2006 and it basically did it for you. In 2015, there is no excuse to do UA sniffing -- if anything, because we now have 20 years of case-history showing people will trivially spoof it.