Quickly view large tables with jQuery

I need to dynamically render large tables using JavaScript and jQuery in particular. I do this by first creating HTML for the table and making append:

var tableHTML = "<table>...</table>"; $("#container").empty().append(tableHTML); 

Is this an acceptable way to solve the problem and if there are faster ways to render the data?

+4
source share
2 answers

Yes, this is the most efficient way to do this with jQuery. If you want to get really fast, you can use Javascript bare bones:

 document.getElementById('container').innerHTML = tableHTML 
+5
source

Instead of using

 $("#container").empty().append(tableHTML); 

you can just use

 $("#container").html(tableHTML); 

who will achieve the same. using plain old javascript may speed things up, but you will also need to remove any event handlers that you bound to the table with your code before deleting the old content, since jQuery usually handles this for you.

+3
source

All Articles