In javascript 'If mobile phone'

$(window).resize(function(){  /*Bind an event handler to the "resize"*/
  if ($(window).width() < 480 || $(window).height() < 480) {
      //what you have to do here
    }
})

I think this answer is better because it doesn't depends on screen width:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
    // some code..
}

I know that now you've got a brand browser dependency, but this is a bit more maintainable that checking for the screen size.


I know this is a very late answer and you have probable solved your problem. But anyways, here is what I use for all of my projects:

window.isMobile = /iphone|ipod|ipad|android|blackberry|opera mini|opera mobi|skyfire|maemo|windows phone|palm|iemobile|symbian|symbianos|fennec/i.test(navigator.userAgent.toLowerCase());

You could use screen dimensions, that way you load your small UI for small screens:

if ($(window).width() < 480 || $(window).height() < 480) {
    //small screen, load other JS files
    $.getScript('/js/script.js', function () {
        //the script has been added to the DOM, you can now use it's code
    });
}

Docs for $.getScript(): http://api.jquery.com/jquery.getscript