I have a script myscript.js
that should only be active if the window width is 960px or larger.
I have included jQuery as follows.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
And the following is my attempt at loading my script under the desired conditions.
if ($(window).width() < 960) {
alert('Less than 960');
}
else {
alert('ok');
$.getScript( 'myscript.js' );
}
However, this is not achieving the desired results.