mobile simple detection

Benchmark created on


Preparation HTML

<script>

var ios, android, blackBerry, windows, smartphone, tablet, all;

var mobileCheck = {
  ios: (function(){
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  }()),
  android: (function(){
    return navigator.userAgent.match(/Android/i);
  }()),
  blackBerry: (function(){
    return navigator.userAgent.match(/BB10|Tablet|Mobile/i);
  }()),
  windows: (function(){
    return navigator.userAgent.match(/IEMobile/i);
  }()),
  smartphone: (function(){
    return (window.innerWidth <= 384 && window.innerHeight <= 640);
  }()),
  tablet: (function(){
    return (navigator.userAgent.match(/Tablet|iPad|iPod/i) && window.innerWidth <= 1280 && window.innerHeight <= 800);
  }()),
  all: (function(){
    return navigator.userAgent.match(/Android|BlackBerry|Tablet|Mobile|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
  }())
};

var mobileCheck_2 = {
  ios: (function(){
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  }),
  android: (function(){
    return navigator.userAgent.match(/Android/i);
  }),
  blackBerry: (function(){
    return navigator.userAgent.match(/BB10|Tablet|Mobile/i);
  }),
  windows: (function(){
    return navigator.userAgent.match(/IEMobile/i);
  }),
  smartphone: (function(){
    return (window.innerWidth <= 384 && window.innerHeight <= 640);
  }),
  tablet: (function(){
    return (navigator.userAgent.match(/Tablet|iPad|iPod/i) && window.innerWidth <= 1280 && window.innerHeight <= 800);
  }),
  all: (function(){
    return navigator.userAgent.match(/Android|BlackBerry|Tablet|Mobile|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
  })
};

var mobileCheck_3 = {
  ios: function(){
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  },
  android: function(){
    return navigator.userAgent.match(/Android/i);
  },
  blackBerry: function(){
    return navigator.userAgent.match(/BB10|Tablet|Mobile/i);
  },
  windows: function(){
    return navigator.userAgent.match(/IEMobile/i);
  },
  smartphone: function(){
    return (window.innerWidth <= 384 && window.innerHeight <= 640);
  },
  tablet: function(){
    return (navigator.userAgent.match(/Tablet|iPad|iPod/i) && window.innerWidth <= 1280 && window.innerHeight <= 800);
  },
  all: function(){
    return navigator.userAgent.match(/Android|BlackBerry|Tablet|Mobile|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
  }
};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
mobileCheck
ios = mobileCheck.ios;
android = mobileCheck.android;
blackBerry = mobileCheck.blackBerry;
windows = mobileCheck.windows;
smartphone = mobileCheck.smartphone;
tablet = mobileCheck.tablet;
all = mobileCheck.all;
ready
mobileCheck_2
ios = mobileCheck_2.ios;
android = mobileCheck_2.android;
blackBerry = mobileCheck_2.blackBerry;
windows = mobileCheck_2.windows;
smartphone = mobileCheck_2.smartphone;
tablet = mobileCheck_2.tablet;
all = mobileCheck_2.all;
ready
mobileCheck_3
ios = mobileCheck_3.ios();
android = mobileCheck_3.android();
blackBerry = mobileCheck_3.blackBerry();
windows = mobileCheck_3.windows();
smartphone = mobileCheck_3.smartphone();
tablet = mobileCheck_3.tablet();
all = mobileCheck_3.all();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.