DOM 中存在大量元素是不是很糟糕?
我已经将 jCarousel 踢到做我想做的事情:
- 按 AJAX 添加面板
- 接近当前组的末尾, go 和 AJAX 一些新面板并插入它们
这工作正常,但似乎对先前的元素调用 jQuery 的 remove()
会导致丑陋的碰撞。我不确定调用 hide()
是否会释放任何资源,因为该元素仍然存在(并且该元素无论如何都会离开屏幕)。
我见过这个,并尝试了carousel.reset ()
在回调中。它只是清除所有元素。
它将在 Windows XP 上的 Google Chrome 上运行,并且仅在液晶电视上显示。
我想知道,如果我无法找到一个合理的解决方案来删除额外的 DOM 元素,它会让我的应用程序陷入困境,还是 Chrome 会进行一些巧妙的垃圾收集?
或者,你会如何解决这个问题?
谢谢
I am making a real estate non interactive display for their shop window.
I have kicked jCarousel into doing what I want:
- Add panels per AJAX
- Towards the end of the current set, go and AJAX some new panels and insert them
This works fine, but it appears calling jQuery's remove()
on the prior elements cause an ugly bump. I'm not sure if calling hide()
will free up any resources, as the element will still exist (and the element will be off screen anyway).
I've seen this, and tried carousel.reset()
from within a callback. It just clears out all the elements.
This will be running on Google Chrome on Windows XP, and will solely be displaying on LCD televisions.
I am wondering, if I can't find a reasonable solution to remove the extra DOM elements, will it bring my application to a crawl, or will Chrome do some clever garbage collecting?
Or, how would you solve this problem?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以重用旧元素而不是删除它们并添加新元素吗?
Could you reuse old elements instead of removing them and adding new ones ?
我找到了一个修复方法,结果非常简单!
只需将其传递给 jCarousel 的配置
基本上,这只会在列表元素变得不可见时将其删除(滚动到负
overflow:hidden
区域,如果你愿意的话:))I worked out a fix that ended up being very simple!
Simply pass this to the config for jCarousel
Basically, this just removes the list element as soon as it becomes invisible (scrolled into negative
overflow: hidden
territory, if you will :) )