You could either try to retrieve the user agent and use that information to decide if you want to include your smooth scroll script. Another solution would be to check for browser width and then decide if you want to include the script or not.
<script>
(function ($) {
if(is_touch_device()) {
$.when(
$.getScript( "/mypath/myscript1.js" ),
$.getScript( "/mypath/myscript2.js" ),
$.getScript( "/mypath/myscript3.js" ),
$.Deferred(function( deferred ){
$( deferred.resolve );
})
).done(function(){
//place your code here, the scripts are all loaded
});
}
})(jQuery);
</script>
Using when() requires jQuery 1.5 or higher, getScript() was added in 1.0.
EDIT as travis stated you could also look for the touch event.
In that case you should use:
function is_touch_device() {
return !!('ontouchstart' in window) // works on most browsers
|| !!('onmsgesturechange' in window); // works on ie10
};
Snippet above from the second SO answer here: What's the best way to detect a 'touch screen' device using JavaScript?