This isn't terribly surprising. In the first case you're inserting 1000 elements, in the second case you're inserting a single element (which so happens to have a bunch of child elements). It's always going to be faster to insert a single element instead of 1000 elements.
--John On Mon, Mar 2, 2009 at 8:29 PM, seasoup <[email protected]> wrote: > > Given: > var newTr = ''; > for (var a = 0; a < 1000; a++) { > newTr += ('<tr>test</tr>'); > } > > This: > $('#testTable').append(newTr); > > is about 6 times slower (in Firefox 3.06 with jQuery 1.3.2) then: > $('#testTable').append('<tbody>' + newTr + '</tbody>'); > > I'm not sure if anything can be done about this, given that forcing a > tbody into tables without them doesn't seem like something one would > want to do in the append code, but thought I would point out a > potential area for speed increase. > > Thanks, > Josh Powell > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---
