selector test id/id id/id class (v13)

Revision 13 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>
function getObject(elementType, elementId) {
        if (elementId.indexOf('/') == -1) {
                return $(elementType + '#' + elementId);
        } else {
                return $(elementType + '[id="' + elementId + '"]:first');
        }
}
</script>

<div id="Mytbl">
<div id="MyElement"></div>
<div class="MyClass"></div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Direct ID
$('#MyElement');
ready
ID=
$('[id="MyElement"]');
ready
function
getObject('', 'MyElement');
ready

Revisions

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