https://github.com/faisalman/ua-parser-js
var deviceType = new UAParser().getDevice().type; if (deviceType === "tablet") { } else { }