Thanks for your suggestion. I think it may help but it won't completely solve the problem. Let me give a little background on what I'm actually trying to do. In response to an Ajax call the server returns an array of component updates that need to be applied to the page. Updates include DELETE, INSERT, UPDATE. Delete is easy, insert and update is where the performance is bad. For each component the server provides component id in DOM, it's parent id and the HTML markup, which can include nested <SCRIPT> elements. I've posted my algorithm below:
http://pastemonkey.org/paste/47137e93-0d2c-4e13-b8c7-263e404fdb0d Your suggestion may help me with UPDATE - I can do something like $(state.componentId).html(state.html) Calling .html() function on a parent would empty it which is wrong - there may be an update for 1 child out of 3. But how would I do the INSERT? Should I just use DOM's createElement() and appendChild() directly? Or use innerHTML? And would it execute <SCRIPT> elements? In general, does anybody know why jQuery has that regexp in the constructor - I assume there is a good reason why they are doing it. On Oct 14, 6:59 am, Wizzud <[EMAIL PROTECTED]> wrote: > With no indication of what either the 'parent' HTML structure or the > JSON structure is like, is it possible to switch from ... > > var $component = $(state.html); > $component.appendTo(parent); > > ...to... > > $(parent).html(state.html); > > (You wouldn't need to empty parent first - html() does that for you) >