Detecting mobile browsers

const isMobile = Math.min(window.screen.width, window.screen.height) < 768 || navigator.userAgent.indexOf("Mobi") > -1;

Source: https://medium.com/@rchr/detecting-mobile-browsers-with-one-line-of-javascript-109713d5869c