Document fragment vs html element append
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul id="container">
</ul>
<script>
Benchmark.prototype.setup = function() {
var ITERATIONS = 1000;
};
Benchmark.prototype.teardown = function() {
document.getElementById("container").innerHTML = "";
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
HTML element append |
|
pending… |
Fragment append |
|
pending… |
jQuery append |
|
pending… |
jQuery append alt |
|
pending… |
construct string + good ol' innerHTML |
|
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 Justin Johnson
- Revision 3: published by Simo
- Revision 4: published by Matthew Miller
- Revision 5: published by Matthew Miller
- Revision 6: published by Rajesh Jagannathan
- Revision 7: published
0 comments