jQuery vs parseHTML vs createElement

JavaScript performance comparison

Revision 135 of this test case created by Ilia Nekhay

Info

Benchmarks from answer on StackOverflow: http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent/268520

Preparation code

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

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
$('...')
$('<br/><p>Choose the correct variant</p><questions>    <question>      1.              <answers>                       <answer correct="true">Moscow</answer>                  <answer>London</answer>                 <answer>the UK</answer>         </answers>              Russia  </question>     <question>              2.              <answers>                       <answer>Yours</answer>                  <answer correct="true">Dear</answer>                    <answer correct="true">Best regards</answer>            </answers>              Alice   </question>     <question>              3.              <answers>                       <answer>Cheers</answer>                         <answer>Nice</answer>                   <answer correct="true">Thanks</answer>          </answers>              for your letter.        </question>     <question>              4.              It was great to         <answers>                       <answer>see</answer>                    <answer correct="true">hear</answer>                    <answer>listen</answer>                 </answers>              from you.       </question>     <question>              5.              <answers>                       <answer>When</answer>                   <answer>Why</answer>                    <answer correct="true">How</answer>             </answers>              are you?        </question>     <question>              6.              <answers>                       <answer correct="true">Hope</answer>                    <answer>Need</answer>                   <answer>Can</answer>            </answers>              to hear from you soon.  </question>     <question>              7.              I am            <answers>                       <answer>looking back</answer>                   <answer>looking nice</answer>                   <answer correct="true">looking forward</answer>                 </answers>              to hearing from you.    </question>     <question>              8.              <answers>                       <answer>Ours</answer>                   <answer>Your</answer>                   <answer correct="true">Yours</answer>           </answers>              , Jim.  </question></questions>')
pending…
$($.parseHTML('...'))
$($.parseHTML('<br/><p>Choose the correct variant</p><questions>        <question>      1.              <answers>                       <answer correct="true">Moscow</answer>                  <answer>London</answer>                 <answer>the UK</answer>         </answers>              Russia  </question>     <question>              2.              <answers>                       <answer>Yours</answer>                  <answer correct="true">Dear</answer>                    <answer correct="true">Best regards</answer>            </answers>              Alice   </question>     <question>              3.              <answers>                       <answer>Cheers</answer>                         <answer>Nice</answer>                   <answer correct="true">Thanks</answer>          </answers>              for your letter.        </question>     <question>              4.              It was great to         <answers>                       <answer>see</answer>                    <answer correct="true">hear</answer>                    <answer>listen</answer>                 </answers>              from you.       </question>     <question>              5.              <answers>                       <answer>When</answer>                   <answer>Why</answer>                    <answer correct="true">How</answer>             </answers>              are you?        </question>     <question>              6.              <answers>                       <answer correct="true">Hope</answer>                    <answer>Need</answer>                   <answer>Can</answer>            </answers>              to hear from you soon.  </question>     <question>              7.              I am            <answers>                       <answer>looking back</answer>                   <answer>looking nice</answer>                   <answer correct="true">looking forward</answer>                 </answers>              to hearing from you.    </question>     <question>              8.              <answers>                       <answer>Ours</answer>                   <answer>Your</answer>                   <answer correct="true">Yours</answer>           </answers>              , Jim.  </question></questions>'))
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:

0 comments

Add a comment