I want to be able disable certain scripts that are in the head section of my page when a mobile device is detected.
At the minute I have this:
$(function(){
var mobile;
if (window.width <= 479) {
//don't load these scripts
}
else {
//load all scripts
}
});
I'm struggling to find the code to disable the scripts from running when mobile width is detected. Any help or other ideas would be much appreciated.
window.screen.widthwill give you the device width which might be better for mobiles. I'd also check out Modernizr and it's script loader yepnope.js.