Is $.empty() Enough For Big Ajaxy Apps?
Been working on an App and since it's getting a bit too big I've thinking of ways to improve memory management since the app runs mostly on Javascipt. So every time a navigation it
Solution 1:
$.fn.empty
should be enough, it deletes all data and events associated to the elements and then deletes the elements. It also calls .widget("destroy")
on all jquery-ui widget.js based widgets that are defined on those elements.
It is also important to note that jquery's $.fn.html
method calls $.fn.empty()
on the given element before appending html, therefore, if you are using $.fn.html
, you don't have to call $.fn.empty
Solution 2:
actually my guess was that .html
implies .empty
anyway, also I'm not sure that's true. for the perforamnce part: according to jqfundamentals excelent book it is a recommanded best practice to add content while the element is in .detach()
from the DOM. tried to lock at the code for advice but didn't find it. nice site btw
Post a Comment for "Is $.empty() Enough For Big Ajaxy Apps?"