You're right to question the requirement to add that many divs. But assuming it's necessary, that code is not the fastest way to do it. This would be faster, especially in IE:
var n = 1600; var html = new Array( n + 2 ); html[0] = '<div>'; for( var i = 1; i <= n; ++i ) html[i] = '<div></div>'; html[i] = '</div>'; $( html.join('') ).appendTo('#parentDiv'); There are several reasons this is faster: 1) It stores the HTML text in an array, then joins the array when it's completed. This is much faster than string concatenation in IE. Also: 1a) It preallocates the array at its final length. 1b) It stores the values directly in the array elements instead of using array.push(). 2) It wraps all of the divs in one container div, i.e. the resulting HTML (with whitespace added for clarity) is: <div> <div></div> ... <div></div> </div> Actually I'm not sure if #2 makes a difference in this case - I'd have to test it. But #1 can make a big difference. -Mike > From: [EMAIL PROTECTED] > > I would start by evaluating the requirement for adding 1599 divs. > The way you have written it is probably the most efficent > cross browser way of appending that much content but it will > still crawl. > > On Dec 2, 10:53 am, "Dirceu Barquette" <[EMAIL PROTECTED]> > wrote: > > Hi! > > > > The code: > > for (i = 0; i < 1600 ;i ++) { > > htm += '<div></div>';} > > > > $(htm).appendTo('#parentDiv'); > > > > How can avoid overhead? > > > > thanks, > > > > Dirceu Barquette >