Testing elements against a selector in zepto

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://raw.github.com/madrobby/zepto/master/src/zepto.js"></script>
<div id="test" class="foo bar">Hi</div>
<script>
var html = document.documentElement;
Zepto.fn.is2 = 
html.webkitMatchesSelector?
function(selector){
    return this[0] && this[0].webkitMatchesSelector(selector)
}
:html.mozMatchesSelector?
function(selector){
    return this[0] && this[0].mozMatchesSelector(selector)
}
:$.fn.is

var $div = Zepto(document.getElementById("test"));
var jqDiv = jQuery(document.getElementById("test"));
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Original .is
$div.is("div");
$div.is("#test");
$div.is("div#test");
$div.is(":not(span)");
$div.is(".foo");
$div.is(".foo.bar");
$div.is(".baz");
$div.is("div#test:not(span).foo.bar");
ready
New .is
$div.is2("div");
$div.is2("#test");
$div.is2("div#test");
$div.is2(":not(span)");
$div.is2(".foo");
$div.is2(".foo.bar");
$div.is2(".baz");
$div.is2("div#test:not(span).foo.bar");
ready
jQuery.fn.is
jqDiv.is("div");
jqDiv.is("#test");
jqDiv.is("div#test");
jqDiv.is(":not(span)");
jqDiv.is(".foo");
jqDiv.is(".foo.bar");
jqDiv.is(".baz");
jqDiv.is("div#test:not(span).foo.bar");
ready

Revisions

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