jquery - how to not load entire script if viewport > X -
this question has answer here:
- best way of dynamic script loading 4 answers
my site has jquery zoom feature crashing on tablets. think best approach remove - it's not necessary. i'd not have load if viewport less 980px, can code that?
<script src='js/jquery.zoom.js'></script>
something <script>if viewport > 980px load 'script.js'</script>
?
use ajax function $.getscript()
:
if ($(window).width()>980) { $.getscript('js/jquery.zoom.js'); }
or write out html, if want load synchronously:
if ($(window).width()>980) { document.write("<script src='js/jquery.zoom.js'></script>"); }
Comments
Post a Comment