Do not try to detect if the device is mobile or desktop through the browser, this is less reliable than checking for age at porn site entry. Chrome mobile itself has an option for Chrome desktop , and it's not even an advanced option. It's in the application's basic menu.
If you're trying to determine whether a device is mobile by the browser's user agent , the only thing you'll guarantee is that new mobile browsers will not receive the mobile experience when they access your site. >
If you try to determine if your device is a cell phone by its capabilities (i.e. detect whether the device supports ringing), you will have bizarre results. My laptop, for example, is touch sensitive. Imagine a website with cell layout rendered on a 15 "screen. That's when I did not plug it into the television ...
The right way to develop pages is to be agnostic about the type of device. Serve layout based on resolution, but so it fits automatically to the window without reloading the page. This is possible with the bootstrap, for example, so I recommend it.
Regarding Javascript, detecting whether the browser is mobile is a worse practice. Just because certain functionality has problems in a mobile model does not mean that it will have the same problems in another model, and vice versa. So, from two to one: either you deprive all users of current mobile browsers of something that would be interesting, or you serve potentially broken functionality for everyone. It is best to determine which javascript functions to serve based on the capabilities of the device, not based on the browser name. There are libraries that go a long way in this. I recommend modernizr .