string concatenation or adding dom
JavaScript performance comparison
Preparation code
<div id='container'>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var arr = [],
urlbase = "http://www.somegallery.fr/image/",
$container = $("#container");
for (var i = 0, l = 100; i < l; i++) {
arr.push(urlbase + i);
}
};
Benchmark.prototype.teardown = function() {
$container.empty();
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
append on dom |
|
pending… |
string concatenation |
|
pending… |
append on unattached dom with string concatenation |
|
pending… |
USE THIS: append on unattached dom without string concatenation |
|
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:
- Revision 1: published by JulienW
- Revision 2: published
- Revision 3: published
- Revision 4: published by Andi
- Revision 5: published by jpvincent
- Revision 6: published by Erik Vorhes
- Revision 7: published by Erik Vorhes
- Revision 8: published by Kyle Hammond
- Revision 9: published by Kyle Hammond
- Revision 10: published
- Revision 11: published
0 comments