jQuery next() vs + (plus)

JavaScript performance comparison

Test case created by Ben Everard

Info

I answer this question on Stack Overflow (http://stackoverflow.com/q/6497039/80111) and recommended the .next() function, however someone else recommended the + plus operator (is that the right term), just checking performance of each.

Preparation code

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

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
.next()
$('#abc').next().html('hello');
pending…
+
$('#abc + p').html('hello');
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