String concat + single append vs multiple append (v10)

Revision 10 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<style type="text/css">
  .container { height: 50px; width:100%; overflow:hidden}
</style>
<div class="container">
</div>
<script>
  var cnt = $('.container');
</script>

Setup

cnt.empty();

Test runner

Ready to run.

Testing in
TestOps/sec
String concat + single append
var str = '<div class="sample">test</div>'
+ '<div class="sample2">test</div>';
+ '<div class="sample3">test</div>';
+ '<div class="sample4">test</div>';
+ '<div class="sample5">test</div>';

$('.container').append(str);
ready
Multiple append
$('.container')
  .append('<div class="sample">test</div>');
$('.container')
  .append('<div class="sample1">test</div>');
$('.container')
  .append('<div class="sample2">test</div>');
$('.container')
  .append('<div class="sample3">test</div>');
$('.container')
  .append('<div class="sample4">test</div>');
ready
append fragments array
var str = [];
str.push('<div class="sample">test</div>');
str.push( '<div class="sample2">test</div>');
str.push( '<div class="sample3">test</div>');
str.push( '<div class="sample4">test</div>');
str.push( '<div class="sample5">test</div>');

$('.container').append(str.join(''));
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.