title: Slow loading speed when using window.onload
body: <p>I'm using this script to hide the <code>div</code> with the id <code>#main-slider</code>.</p>
  
  <p>But every time I load my page I can see the div for like 1 or 2 seconds and then it disappears, is there any way to make it take effect sooner? </p>
  
  <p>Thank you.</p>
  
  <pre><code>window.onload = function() {
      if($(window).width() &gt; 991) 
      {
          $('#main-slider').removeClass('hidden');
      }
      else
      {
          $('#main-slider').addClass('hidden');
      }
  }
  </code></pre>