pjiwrpjiwrgpjior

Benchmark created by yc on


Preparation HTML

<a href="http://fiddle.jshell.net"></a>
<a href="http://foo.net"></a>
<a href="/foodnet"></a>
<b><span></span></b><div><div></div><div>
<a href="http://jshell.net"></a>
<area>
<map href="http://google.com" />
</area>
<a href="http://jsperf.com"></a>
<a href="//jsperf.com"></a>
<a href="/jsperf"></a>

 <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var regex = /^(https?:|\/\/)/;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
filter host and href
$('a,map').filter(function(i) {
 return regex.test($(this).attr('href'));
});
ready
host then test
$('a,map').filter(function(i) {
 return this.host !== location.host && regex.test($(this).attr('href'));
});
ready
test then hosT
$('a,map').filter(function(i) {
 return regex.test($(this).attr('href')) && this.host !== location.host;
});
ready
old
$('[href^="http"]');
ready
old exp
$('[href^="http"]').filter(function(i) {
 return this.host !== location.host;
});
ready

Revisions

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