user235273
user235273

Reputation:

Does using jquery.detach() improve performance?

Does using jquery.detach() and doing operations on the detached node and the appending it improve performance?

Upvotes: 1

Views: 272

Answers (1)

doug65536
doug65536

Reputation: 6781

It causes a memory leak if you don't put the element(s) back in the document somewhere. jQuery will keep all the data (as in element.data() and references to event handlers) in memory when you use .detach.

That is the purpose of .detach: to not clean up because you are promising to put the elements back into the page soon. If you were not going to put them back, you would use .remove and that would clean up the data.

It is not about performance.

Upvotes: 1

Related Questions