Create tag with jquery (v2)

Revision 2 of this benchmark created on


Description

Which of the techniques is faster to create a tag in jquery.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var johnLewis = {};
  johnLewis.Module = {};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Using variable
var mask = '<div class="modClass"></div>',
    maskElem = $(mask);
ready
straight into object
var straightMask = $('<div class="modClass" />');
ready
default
var straightMask = document.createElement('div');
straightMask.className = 'modClass';
 
ready

Revisions

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