String concatenation vs document.createDocumentFragment()
JavaScript performance comparison
Preparation code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<div id="body">
</div>
<script>
Benchmark.prototype.setup = function() {
var html;
var obj = {
header: 'header test',
body: 'body text lorem ipsum'
};
var doc = window.document;
var body = doc.getElementById('body');
};
Benchmark.prototype.teardown = function() {
html = '';
$(body).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 | |
|---|---|---|
String |
|
pending… |
fragment |
|
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 Marcin
- Revision 2: published by Helge Rausch
- Revision 4: published by Marcin
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 11: published
- Revision 12: published
0 comments