jquery - how to not load entire script if viewport > X -


this question has answer here:

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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -