$(window).scroll(function() {
/*----------------------------------
sticky block script by makeasite.ru
----------------------------------*/
sb_m var = 20; /* indent on top and bottom */
var mb = 300; /* height of the footer with margin */
var st = $(window).scrollTop();
var sb = $(".sticky-block"); // Block wrapper
var sbi = $(".sticky-block .inner"); // Floating unit
var sb_ot = sb.offset().top;
var sbi_ot = sbi.offset().top;
var sb_h = sb.height();
if(sb_h + $(document).scrollTop() + sb_m + mb < $(document).height()) {
if(st > sb_ot) {
var h = Math.round(st - sb_ot) + sb_m;
sb.css({"paddingTop" : h});
}
else {
sb.css({"paddingTop" : 0});
}
}
});
var sb = $(".sticky-block");
jQuery You are using slow-designs that make the extra operations, such as sb.css({"paddingTop" : h});
instead of the more rapid design in pure JS: sb[0].style.paddingTop = h + "px";
Find more questions by tags jQuery