title: How to set HTML Table column widths explicitly in JavaScript
body: <p>I have hit a scaling problem with an HTML table, whilst manipulating it in JavaScript.  </p>
  
  <p>I have a JavaScript code blob that dynamically creates a table from a JSON array.
  It fixes the header and allows the table body to scroll, and it works well.</p>
  
  <p>The header is a separate table, and I strongly control cell widths to ensure that the header table's cells match up with the body table cells.</p>
  
  <p>The body table cells all have their width explicitly set.<br>
  I iterate the rows in the table, and then interate the cells within that loop, and set each cells width.</p>
  
  <p>This iteration is not scaling, as the rows grow to 100 and the columns get to 40 odd, I get complaints from Firefox that the script is hanging or unresponsive.  It is unresponsive, because it is busy setting all the cell widths.</p>
  
  <pre><code>nz.dynatable.setTableColumnWidths = function (table, arrayColumnWidths) {
      // Iterate the table and set width settings for each cell
      for (var i = 0; i &lt; table.rows.length; ++i) {
          for (var j = 0; j &lt; table.rows[i].cells.length; ++j) {
              var width = arrayColumnWidths[j] || 0;
              table.rows[i].cells[j].style.width = width.toString() + "px";
          }
      }
  }
  </code></pre>
  
  <p>Q: Is it possible to to set cell widths for a table in one row and have all the other cells in the table fall into line with this?  Is Firefox getting whacked because changing the cell widths is causing it to recalc the table size on each loop?</p>
  
  <p>The full code chunk is in a public GitHub repo: <a href="https://github.com/Hiblet/DynaTable" rel="nofollow">https://github.com/Hiblet/DynaTable</a></p>