0

I hear $(window).scroll is bad for performance are there any alternative method to find out the position from the top?

For example between these?

$(window).scroll(function() {

     if($(this).scrollTop() > 500)   
    {
        $('.class').addClass('class2');
    } else {
        $('.class').removeClass('class2t');
    }

});

or:

offset().top

or:

.position().top

or any other methods? like Pure JavaScript? which one is best/preferred according to modern standards today?

user2513846
  • 1,151
  • 2
  • 16
  • 39

0 Answers0