JQuery Clone Performance

I read that javascript gets significant performance benefits from off-dom modifications. Earlier today I read the clone documentation:

"Please note that when using the .clone () method, we can modify the cloned elements or their contents to (re) inserting them into the document."

Is the implication that if I have 1000 LI and I want to make changes in all of them, the most effective method would be to clone, modify the clone, destroy the original and place the clone?

How could you make this modification the most efficient way?

+3
source share
3 answers

detach() - , , :

http://api.jquery.com/detach/

: , /, , . , .:)

: , , .detach(), - addClass, detach.

"", .

, : http://jsbin.com/uwode3/5 vs http://jsbin.com/uwode3/4

+3

, , , DOM, , . , clone-modify-replace , , , , ... , , , .

... ... "" DOM : removeChild() (, jQuery, detach()) - , , , .

... , , , UL, 1K LI, ...

+6

: .detach() , , .
, DOM , ( ) , , firefox ( , ). , , , .

+2

Source: https://habr.com/ru/post/1751809/


All Articles