Alternative to appendChild() function

Discussion in 'JavaScript' started by gangireddyit, Aug 25, 2008.

  1. #1
    Hi ,

    I am using javascript appendChild() function which is very slow, i need an alternative for this which will improve my system performance. the following is the code snippet

    if(t.tBodies[count].id != null && t.tBodies[count].id == "dataRows"){
    for (j=0;j<t.tBodies[count].rows.length;j++) {
    t.tBodies[count].appendChild(sortRows[j]);
    document.all("mainTable")[1].tBodies[count].rows[j].cells[0].innerHTML = sortRows[j].cells[0].innerHTML;
    }
    }

    in the above i need an alternative to t.tBodies[count].appendChild(sortRows[j]); which is taking more time , please help in this
     
    gangireddyit, Aug 25, 2008 IP
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is the code doing? It might be simpler to rewrite it! :-/
     
    Wrighty, Aug 25, 2008 IP
  3. gangireddyit

    gangireddyit Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    we are using the above code in table sorting, sorting is happening perfectly, after sorting we are appending the sorted rows to the same table using appendChild() method which is taking more time, our performance is poor, to improve the performance we have to optimize code i.e appendChild() method i.e we need an alternative for this.
     
    gangireddyit, Aug 25, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    I honestly think it has more to do with the "innerHTML" usage than "appendChild".
     
    joebert, Aug 29, 2008 IP