Skip to content

Instantly share code, notes, and snippets.

@gdibble
Created March 11, 2022 00:07
Show Gist options
  • Select an option

  • Save gdibble/1fc987aa55bdcb8c2f5aafe551492a70 to your computer and use it in GitHub Desktop.

Select an option

Save gdibble/1fc987aa55bdcb8c2f5aafe551492a70 to your computer and use it in GitHub Desktop.

Revisions

  1. gdibble created this gist Mar 11, 2022.
    7 changes: 7 additions & 0 deletions isMobile.const.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    /** isMobile - Feature Detection of an actual mobile device
    * @description The localStorage.mobile works in Chrome mobile; the latter works in Safari mobile.
    * Does not trigger desktop browsers with or w/o the dev-tools open and/or on a mobile simulator.
    * @see https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser/71030087#71030087
    */

    const isMobile = localStorage.mobile || window.navigator.maxTouchPoints > 1;