• Ryan DeBeasi, almost 7 years ago (edited almost 7 years ago )

    This is really clever, and it's especially useful for Modernizr's undetectables.

    That said, in many cases it's simpler and more reliable to detect features, adjust for screen size, or simply accept that browsers render some elements differently (e.g, text). This is particularly true if the browser fixes the bug that you're working around, and suddenly the workaround becomes the cause of a problem rather than the solution. I worry that this approach is so convenient that it could encourage people to use UA sniffing when a better solution is available.

    I'd add that not all cross-browser differences are bugs. Sometimes various standards-compliant browsers interpret the standards in slightly different ways, or add little features on top of the standards.

    To me, user agent sniffing is a last resort (see this article for more on why). That said, if you have to do it, you might as well use a clever tool like this one. :)

    3 points
  • Caleb WintersCaleb Winters, almost 7 years ago

    This is incredible! Thanks Rogie. :)

    0 points
  • Alex PopescuAlex Popescu, almost 7 years ago

    is there a comprehensive / up to date user agent list to be found anywhere?

    0 points
    • Rogie KingRogie King, almost 7 years ago

      Alex, not sure, but you could always inspect element on the browser of your choice to see what it reports or open the console and slam in navigator.userAgent

      0 points
  • Alex PopescuAlex Popescu, almost 7 years ago

    brilliant! are there any potential downsides to this technique though? is data-useragent* behaviour slower to compute for the browser or plainly negligible?

    0 points
    • Rogie King, almost 7 years ago

      Alex, that's the only downside I could possibly think of. Attribute selectors on large strings could get unwieldy, however I've used this technique for well over 2 years, but mostly on websites not webapps.

      1 point
  • Julian LengfelderJulian Lengfelder, almost 7 years ago

    Woah! Nice one! Thanks a lot!

    0 points
  • Henrique Alves, almost 7 years ago

    Nice one Rogie!

    0 points
  • Cole RobertsCole Roberts, almost 7 years ago

    This is brilliant! Thank you!

    0 points
  • ポール ウェッブポール ウェッブ, almost 7 years ago

    Rogie, you're a genius.

    0 points