width test

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<table>
 <tr>
   <td>23444</td>
<td>2</td>
<td>23443223</td>
<td>3</td>
<td>44</td>
<td>343</td>
<td>5434534</td>
<td>ewrt</td>
<td>43534534543</td>
<td>345543344354</td>
<td>234234</td><td>2344323</td>
<td>233432</td>
<td>4444</td>
<td>33</td>
<td>2342</td>
<td>234432</td>
<td>234234</td>
<td>443223</td>
<td>24324</td>
<td>2342342</td>
<td>33</td>
<td>3423</td>
<td>23423</td>
<td>345453434</td>
<td>34543543</td>
<td>54343543</td>
<td>345</td>
<td>23423</td>
<td>43232</td>
<td>234432</td>
 </tr></table>

Preparation code output

23444 2 23443223 3 44 343 5434534 ewrt 43534534543 345543344354 2342342344323 233432 4444 33 2342 234432 234234 443223 24324 2342342 33 3423 23423 345453434 34543543 54343543 345 23423 43232 234432

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jQuery Modify Width
$td = $("table tr td:first-child");
while($td.length > 0) {
    w = $td.width();
    $td.width(w+1);
    $td = $td.next("td");
}
pending…
CSS Modify Width
$td = $("table tr td:first-child");
while($td.length > 0) {
    w = parseFloat($td.css("width"));
    $td.css("width", (w+1)+"px");
    $td = $td.next("td");
}
pending…
No width check
$td = $("table tr td:first-child");
while($td.length > 0) {
    $td = $td.next("td");
}
pending…
jQuery Read Width
$td = $("table tr td:first-child");
while($td.length > 0) {
    w = $td.width();
    $td = $td.next("td");
}
pending…
CSS Read Width with parse
$td = $("table tr td:first-child");
while($td.length > 0) {
    w = parseFloat($td.css("width"));
    $td = $td.next("td");
}
pending…
CSS Read Width without parse float
$td = $("table tr td:first-child");
while($td.length > 0) {
    w = $td.css("width");
    $td = $td.next("td");
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment