How can I use `javascript` to detect mobile browsers reliably?

Hey, I’ve done a fair bit of lightweight front-end work, and for small projects, you really can get by with a simple navigator.userAgent regex check.

function isMobileDevice() {
  return /Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}

console.log(isMobileDevice()); // true or false

:brain: Why I use this: When I was hacking together a landing page that just needed a few javascript detect mobile tweaks (like hiding some animations on phones), this quick snippet was all I needed. No need for heavy libraries or over-engineering — just match the known strings and move on.