I want to load a particular jQuery script/function in desktop browsers, but not mobile browsers. At the moment, the script runs very slow on mobile browsers, but works fine on desktop browsers.
The function in question is a smooth scrolling plugin, so that when a user clicks a link, the page scrolls smoothly to the anchor on the same page. It is not necessary for it to scroll smoothly on mobile browsers - it is too slow, and often doesn't work.
What would I need to add to my code below to ensure that it is still executed as normal in desktop browsers, but not mobile (particularly iPad/iPhone/iPod)?
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/lib/jquery/jquery.js"%3E%3C/script%3E'));</script>
<script src="js/css_browser_selector.js"></script>
<script src="js/src/jquery.smooth-scroll.js">
</script>
<script src="js/lib/jquery.ba-bbq.js"></script>
<script>
$(document).ready(function() {
$('a[href*="#"]').live('click', function() {
if ( this.hash ) {
$.bbq.pushState( '#/' + this.hash.slice(1) );
return false;
}
});
$(window).bind('hashchange', function(event) {
var tgt = location.hash.replace(/^#\/?/,'');
if ( document.getElementById(tgt) ) {
$.smoothScroll({scrollTarget: '#' + tgt});
}
});
$(window).trigger('hashchange');
});
</script>