ismobile
v1.0.1
Published
Stupid simple mobile detection script for node.js and express
Downloads
51
Readme
isMobile-node
Stupid simple mobile detection script for node.js and express
Usage
This small script allows you to control what gets sent to mobile and desktop in the templating layer. Its middleware and needs to be included in your app.configuration like so
app.configure(function(){
// your setup
require('isMobile')(app); // this must be BEFORE
app.use(app.router); // app.router!
// continuing your setup
});
Now you can use if blocks in your templates (jade shown here) using the two key variable isMobile
and isDesktop
:
html
head
title detection basic
if isDesktop
//- include desktop css here
else
//- include mobile css here
body
if isMobile
h1 Its Mobile!
else
h1 Its Desktop!
Thats it! Like it says, stupid simple. Here is the one thing to be aware of, this script treats tablet computers as desktops. If you want to serve the mobile version of your site to an iPad, this script is not for you (atleast not this version); also you should be ashamed for annoying me as an iPad user.