jquery - Which selector is faster? -
i'm searching existance of 1 matching selector. faster?
$('a[rel="something"]').first().length > 0)
or
$('a[rel="something"]').length > 0)
thanks!
$('a[rel="something"]').length > 0)
should faster because not have overhead of picking (finding out) first()
element in wrapped set $('a[rel="something"]')
.
and if targeting 1 element $('a[rel="something"]')
, using first()
isn't needed anyway.
Comments
Post a Comment