Browser detection can be useful sometimes but should be avoided.
To detect the current browser, you can use the global Liferay.Browser
object and its various functions.
You'll notice that this Liferay.Browser
object actually wraps BrowserSnifferUtil
, meaning that both the server (java) and client (js) will be in "sync".