jQuery .first() vs :first selector (v3)

Revision 3 of this benchmark created by Joshua Piccari on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<form accept-charset="UTF-8" action="/signin" data-remote="true" id="new_session" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="uK7TWhn6mJvofc7+FpiZuda7sbKqgRPSfv+ebpYRv0k=" /></div>
        
        
        <div class="control-group">
                <div class="field_with_errors"><label for="session_username">Username:</label></div>
                <div class="field_with_errors"><input class="input-block-level" id="session_username" name="session[username]" placeholder="Username" size="30" type="text" /></div></div>

                <div class="field_with_errors"><label for="session_password">Password:</label></div>
                <div class="field_with_errors"><input class="input-block-level" id="session_password" name="session[password]" placeholder="Password" size="30" type="password" /></div>
        </div>
        
        <div class="actions">
                <input class="btn btn-success" type="submit" value="Sign In" />
                <div class="ajax-loader" style="display: none;"></div>
        </div>
</form>

Test runner

Ready to run.

Testing in
TestOps/sec
.first()
$('form').find('.field_with_errors *:input').first();
ready
:first
$('form').find('.field_with_errors *:input:first');
ready

Revisions

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