|
|
1
3
detach()方法是为您正试图执行的操作而设计的方法: Edit: It's worth a mention that everyone do their own profiling/tests, which is good, common sense advice. Plus it's fun to see the ridiculous performance gains you'll get. :) My rule of thumb is this: If you're doing manipulations on many elements that involves adding or removing or moving elements around, you should absolutely use .detach(), if you're doing something like addClass, don't use detach. If you're unsure about specific manipulations or how many qualifies as 'many', you should run a test. 下面是我在这个问题的辩论中做的一个简单比较: http://jsbin.com/uwode3/5 VS http://jsbin.com/uwode3/4 |
|
|
2
6
Actually, the implication is that it would be more efficient to modify cloned elements before inserting them into the DOM than to insert the cloned elements into the document 然后修改它们 . Whether or not clone-modify-replace is more efficient than simply modifying the elements in-place will likely depend a 许多 关于你打算做什么修改…一如既往, 分析您的代码 然后根据实际数据选择最能满足您需求的选项。
…当你在做的时候…您可以直接“分离”一个dom元素:只需调用
...Oh, and regardless of which technique you end up using, you'll almost certainly see better results from removing the parent UL than from removing each of the 1K child LI elements, one at a time... |
|
|
3
2
还有一种更有效的方法:
|
|
Sweepy Dodo · JSON lite的格式化 1 年前 |
|
|
giantjenga · 优化整数向量到二进制向量的转换 1 年前 |
|
Zegarek · Postgresql递归查询未提供预期结果 1 年前 |
|
|
Joe · 为什么这两个查询之间的性能存在如此大的差异? 1 年前 |
|
tic-toc-choc · 在`dplyr中高效使用列表进行过滤` 2 年前 |