id vs class selector jquery 345324

JavaScript performance comparison

Test case created

Preparation code

<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div id="item" class="items"><p>Testing</p></div>
</body>
</html>

Preparation code output

Testing

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
id
$('#item').find('p');
pending…
class
$('.items').find('p');
pending…

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

Compare results of other browsers

0 comments

Add a comment