Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to generate a lot of tables from different jsonfiles (up to 20 tables per page). Because it's a lot of data, I really want to keep loading speed in mind. I know it's better to use a non jQuery solution, but native is not in my skillset right now.

$(document).ready(function(){

  (function getPersonData(){
   $.getJSON('path/to/json', function(data){


  (function addPersonsTable1(personsData){

    var elementContainer = '';

    $.each(personsData.persons, function(key, person){      
      elementContainer = elementContainer + '<tr>' +
        '<td>' + person.value1 + '</td>' + 
        '<td>' + person.value2 + '</td>' + 
        '<td>' + person.value3 + '</td>' + 
        '<td>' + person.value4 + '</td>' + 
        '<td>' + person.value5 + '</td>' + 
      '</tr>';
    });

    $('.persons-table-1').append(elementContainer);

  }(data));

  (function addPersonsTable2(personsData){

    var elementContainer = '';

    $.each(personsData.persons, function(key, person){      
      elementContainer = elementContainer + '<tr>' +
        '<td>' + person.value1 + '</td>' + 
        '<td>' + person.value2 + '</td>' + 
        '<td>' + person.value3 + '</td>' + 
        '<td>' + person.value4 + '</td>' + 
        '<td>' + person.value5 + '</td>' + 
      '</tr>';
    });

    $('.persons-table-2').append(elementContainer);

  }(data));


  /*
  *
  *
  *
  *
  *  <..... And many more tables
  *
  *
  *
  *
  */

 }).done(function(){
  loadedAnimation();
});

});
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.