Could someone offer insight into why my JavaScript code is performing slowly?
Are there any optimizations I can implement to improve its speed?
Thank you!
$(document).ready(function() {
/* Trigger animation when window is scrolled */
$(window).scroll( function(){
/* Check the position of each target element */
$('.hideme').each( function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* Fade in element if it's fully visible in window */
if( bottom_of_window > bottom_of_object ){
$(this).animate({'opacity':'1'},500);
}
});
});
});