Creating a simple element with class in jQuery

Benchmark created by TeMc on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
HTML string (innerHTML)
$('<div class="fluid-width-video-wrapper" />');
ready
Well-formed HTML string (innerHTML) (for IE compat.)
$('<div class="fluid-width-video-wrapper"></div>');
ready
quickTag + attr map (d.createElement + $.attr)
$('<div>', { 'class' : 'fluid-width-video-wrapper' } );
ready
quickTag + chain (d.createElement + $.fn.addClass)
$('<div>').addClass('fluid-width-video-wrapper');
ready

Revisions

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

  • Revision 1: published by TeMc on