title: browser crashes on resize function
body: <p>I am trying to create a responsive horizontal list navigation, which fits the no. of items based on the screen size. The items that do not fit, will be put in a dropdown menu. This works fine, but now I want to re-execute the script on resize. But as soon as I call the function in the resize function, the browser freezes. I assume it gets stuck in a loop, but I can't seem to debug it. Does anyone see what is wrong?   </p>
  
  <pre><code>    function overflowDropdown() {
  
        'use strict';
  
  
      // Define the context we will be operating in.
        var list = '.action-menu ul';
  
        // Act only if the more tab is not created yet.
        if (typeof $(list) != 'undefined' &amp;&amp; $(list) != false &amp;&amp; $(list).length &gt; 0) {
  
      // We will store any items here that we want to move.
      var itemsToMove = new Array();
  
      // get window width
      var windowWidth = $(window).width();
  
      // define how much items fit one the screen
      var itemsFit = 1;
  
      if (windowWidth &gt; 450) {
        itemsFit = 2;
      }
      if (windowWidth &gt; 600) {
        itemsFit = 3;
      }
  
      // Loop through all items and retrieve the index
      $.each($('li', list), function(index, value) {
  
        // Add everything except the first item to the items_to_move array.
        if (index &gt; (itemsFit - 1)) {
         itemsToMove.push(value);
        }
  
      });
  
      // If there is more than one item to move we proceed here.
      if (itemsToMove.length &gt; 1) {
      // Add our new container div.
        $(list).append('&lt;li class="action-overflowing"&gt;&lt;a data-dropdown="#dropdown-action-menu" class="action-overflowing-trigger" href="#"&gt;&lt;i class="icon icon-menu"&gt;&lt;/i&gt; More &lt;/a&gt;&lt;div id="dropdown-action-menu" class="dropdown dropdown-scroll"&gt;&lt;ul class="dropdown-menu"&gt;&lt;/ul&gt;&lt;/li&gt;');
  
        // Foreach items that need to moved place them in the newly created awesomebox dropdown.
        $.each(itemsToMove, function(index, value) {
          $('#dropdown-action-menu ul', list).append(value);
          $('#dropdown-action-menu').hide();
        });
      }
  
    }
  
  };
  </code></pre>
  
  <p>Resize function:</p>
  
  <pre><code>(function($) {
  
    var resizeTimer; // Set resizeTimer to empty so it resets on page load
  
    function resizeFunction() {
     // some other functions are here that do work
     overflowDropdown()
    };
  
    // On resize, run the function and reset the timeout
    // 1000 is the delay in milliseconds.
    $(window).resize(function() {
      clearTimeout(resizeTimer);
      resizeTimer = setTimeout(resizeFunction, 1000);
    });
  
    resizeFunction();
  
  })(jQuery);
  </code></pre>