clone vs dom editing
JavaScript performance comparison
Info
I want to edit row in text. Want to test if cloning and replacing will be a good option or just editing.
Preparation code
<table id="test-table">
<tr id='tr-1'>
<td>
Test
</td>
<td>
Test
</td>
</tr>
</table>
<style>
table{border-collapse:collapse;} tr.selected td{border:1px solid green;}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
var $row = $("#tr-1");
var rawRow = document.getElementById('tr-1');
};
</script>
Preparation code output
| Test | Test |
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
clone |
|
pending… |
direct dom editing |
|
pending… |
raw js clone |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments