我是否需要删除以前加载的视频以保护页面性能?
我的页面上有视频 - 并且只有视频
由于性能问题 - 页面加载时仅加载一定数量的视频
其余的都是动态加载的 - 比方说 - 像这样:
$(window).scroll(function() {
if($(window).scrollTop() == $(document).height() - $(window).height()) {
// ajax call get data from server and append to the div
}
});
但如果我滚动得足够多 - 页面也会有太多视频 - 例如 1000 个视频 - 不是吗?
所以问题是 - 我是否需要一些代码来删除以前加载的视频(不在视口中)并通过上下滚动再次加载它们?
似乎执行该代码来不断加载/删除视频 - 也会对页面性能造成很大的负担,
有什么建议吗?
On my page there are videos - and only videos
Because of performance issue - only a certain number of videos are loaded on page loading
the rest of them are loaded dynamically - let's say - like this:
$(window).scroll(function() {
if($(window).scrollTop() == $(document).height() - $(window).height()) {
// ajax call get data from server and append to the div
}
});
but if I scroll enough - the page will also have too many videos - for example 1000 videos - isn't it ?
So the question is - do I need some code to remove the previously loaded videos which are not more in the viewport and load them again by scrolling up and down ?
it seems that executing that code for constantly load/remove videos - will also be a big burden for the page performances
any advice ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论