title: How to disable jQuery plugin on window resize
body: <p>I'm trying to implement the window resize event listener so that the jScroll jQuery plugin I'm using doesn't fire on smaller screens where the scrolling of certain items is causing problems.</p>
  
  <p>By putting together a mix of stuff i've read here this is what i've come up with:</p>
  
  <pre><code>&lt;script&gt;    
      $(window).resize(function() {
          windowWidth = $(this).width();
          if (.windowWidth() &gt; 602) {
              $(".sectionTitle").jScroll({speed : "slow",top : 50});
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/20659338/how-to-disable-javascript-in-media-query/">How to disable JavaScript in media query</a> was my main source of help but still haven't got it to work. Any help would be greatly appreciated.</p>
  
  <p>RE the comments:
  this is what I get in the console:</p>
  
  <p>Uncaught SyntaxError: Unexpected token . (index):113
  2
  Uncaught SyntaxError: Unexpected end of input (index):1
  GET <a href="http://ghost-mirror.org/notify_act.php" rel="nofollow noreferrer">http://ghost-mirror.org/notify_act.php</a> net::ERR_NAME_NOT_RESOLVED jquery.js:5</p>
  
  <p>When i dont wrap the jscroll code in the resize function, .sectionTitle follows the users scrolling in the window like a fixed element until it reaches the end of its container.</p>
  
  <p>I updated the code like entiendo stated:</p>
  
  <pre><code>&lt;script&gt;    
  $(window).resize(function() {
      var windowWidth = $(this).width();
      if(windowWidth &gt; 602) {
          $(".sectionTitle").jScroll({speed : "slow",top : 50});
          }
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>If I could just get the plugin to run by default on window widths more than 602px and disabled by default on windows less than 602 i would be super grateful. (At the moment it only runs when I resize the window, so If I load up the page but dont change the size then the script doesnt run).</p>