开发者

HTML, Javascript: How do I load an HTML element when the user scrolls it into view?

开发者 https://www.devze.com 2023-02-02 04:07 出处:网络
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 performa

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消