Skip to content Skip to sidebar Skip to footer

How To Make Mobile Devices Not Load An External Js

I have a website I've taken over which is nearing launch. The website has a script which loads each page ajax style and updates the URL which enables a continuously playing music

Solution 1:

Why is a backend solution not applicable?

Anyway, make sure you include jQuery and the Detect Mobile (jQuery):

<head><scriptsrc="jquery.js"></script><scriptsrc="detectmobilebrowser.js"></script></head>

Now to detect if it's NOT a mobile:

if ( !jQuery.browser.mobile ) {
    // create the script element
}

How do you create the script element?

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://URLTOSCRIPT';

$('body').append(script);

Post a Comment for "How To Make Mobile Devices Not Load An External Js"