How to detect device and operating system using mobile-detect.js plugin

Here I am going to introduce mobile-detect.js, A cool library written in javascript to detect which type of device is using by visitor so that you can display different output for different device holder or operating system holder. By using you can easily and quickly get device types like phone, tablet, desktop, mobile grade, os, versions etc.

This library will detect the device by comparing patterns against a given User-Agent string. You can find out information about the device rendering your web page and take action as per device output.

You can easily judge user device is mobile or not, if mobile, whether phone or tablet, which operating system visitor using and which version is (e.g. WebKit);

Here is the quick configuration.
First of all download mobile-detect.js library from Here

After that add mobile-detect.js on page and call MobileDetect object and pass user agent as parameter see following code.

<script src="mobile-detect.js"></script>
var md = new MobileDetect(window.navigator.userAgent);
console.log( );          
console.log( );           
console.log( md.tablet() );          
console.log( md.userAgent() );       
console.log( md.os() );              
console.log('iPhone') );      
console.log('bot') );         
console.log( md.version('Webkit') );         
console.log( md.versionStr('Build') );       
console.log( md.match('playstation|xbox') ); 

See official page for more details.