Остановка скрипта через промежуток времени

by AJIEKCEU

HTML

<div class="js_preloader"></div>

CSS

.js_preloader{
  background:#000;
    width:500px;
    height:500px;
}

JavaScript

$.fn.preloader_fun = function() {     
    this.each(function() {       
      var y = Math.round(1 + Math.floor(Math.random() + 20));
      var z = Math.round(1000 + Math.floor(Math.random() * 5000));
    
        console.log(y,z);
   
      $(this).animate({      
            height: '-='+ y +'px'
            }, z, "swing",function() {
                $(this).preloader_fun();
              });
    });
return this;    
    
}; 
$(".js_preloader").preloader_fun();