javascript - Disable specific scripts on mobile screen sizes -


my purpose achieve can css links, when add media attribute , can disable css resolution of less n pixels , still load them , use them.

what i'm trying adapt joomla website mobile 1 using jquery , bootstrap, plugins call own scripts , css files when inserted, , can't change behaviour, nor delete scripts because client doesn´t want desktop layout change. css did this:

$(document).ready(function({ $('body').find('link').attr('media', 'screen , (min-width:969px)'); })); 

this works perfect css because still loads, doesn´t interfere mobile layout calls bootstrap. comes next try same scripts, have tried this

$(document).ready(function({ $('body').find('script').each(function(){    var screen = parseint($(window).width());       if(screen>==969){       $(this).removeattr('src');       }    }); })); 

but it's not working, , solution won't work either if screen size change, missing something, or best approach? intention target body since here inserted tags appear. if remove script tags content dekstop not display properly. there media attribute script tags?

for javascript can use mq function of modernizr, allows programmatically check if current browser window state matches media query.

first have load modernizr.js

for example: small = modernizr.mq('only , (max-width: 1200px)'); ... if(small){ ... }


Comments