HTML, Javascript: How do I load an HTML element when the user scrolls it into view?
Such as, in my case, an element at the bottom of each page with a Disqus comment thread inside. These alone take a few seconds to load o开发者_如何学Gon each page, and it would greatly improve performance if they could be loaded only if the user actually views them.
I was about to suggest handling the scroll event and then checking if the element in question has moved into the viewport, but while researching I found this:
jquery-appear - jQuery plugin to call a function when an element becomes visible
(via another question here on SO: jQuery - Check if element is visible after scroling)
精彩评论