title: Fast way to dynamically fill table with data from JSON in JavaScript
body: <p>I am experimenting with jQuery, JSON etc. and came across following task. I have a loader script on the server which returns table data in JSON format. When received the JSON data, I want to fill my table with them. I am currently using code similar to following (there are more columns and some more advanced processing, but you got the idea):</p>
  
  <pre><code>...
  for (var key=0, size=data.length; key&lt;size;key++) {
  
    $('&lt;tr&gt;')
              .append( $('&lt;td&gt;').html(
                  data[key][0]
              ) )
              .append( $('&lt;td&gt;').addClass('whatever1').html(
                  data[key][1]
              ) )
              .append( $('&lt;td&gt;').addClass('whatever2').html(
                  data[key][2]
              ) )
              .appendTo('#dataTable');
  }
  ...
  
  &lt;table id="#dataTable"&gt;&lt;/table&gt;
  ...
  </code></pre>
  
  <p>This works pretty much ok. But once the data is growing it's getting terribly slow. For few hunderts of records it take up to about 5s (Firefox, IE) to build the table and that is a bit slow. If I e.g. create the whole HTML on the server and send it as string which I include in the table it will be pretty fast.</p>
  
  <p>So, is there faster way to fill the table?</p>
  
  <p><strong>NOTE:</strong> I know what is paging and I will use it in the end so please don't say "What do you need such a big table on your page for?". This question is about how to fill table quickly no matter how many records you will display :)</p>