selector API

Benchmark created by Truong Nguyen on


Preparation HTML

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Untitled</title>
    </head>
    <body>
<div id='container'>
            <div class="div1">div1</div>
            <div class='div2'>div2</div>
            <a href="#">link</a>
        </div>
        
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    </body>
</html>

Test runner

Ready to run.

Testing in
TestOps/sec
using JS and DOM
var elements = document.getElementById('container').getElementsByTagName('div');
ready
using querySelectorAll
var el = document.querySelectorAll("#container div");
ready
using jQuery
var el = $("#container div");
ready
jquery
var el = $("#container").find('div');
ready

Revisions

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

  • Revision 1: published by Truong Nguyen on