JSFiddle - React, Tailwind, and code Playground
HTML
<div id="gh-gb">
</div>
<div id="Body">
<div id="TopPanelDF" style="display: inline; ">
<a class="gh-hdn" href="#mainContent">Skip to main content</a>
<div id="gh" class="gh-w gh-site-0">
<table class="gh-tbl">
<tbody>
<tr>
<td class="gh-td">
<a id="gh-la" _sp="m570.l2586" class="iclg" href="http://www.ebay.com">eBay<img alt="" src="http://p.ebaystatic.com/aw/pics/s.gif" id="gh-logo" class="gspr iclg" border="0"></a>
</td>
<td class="gh-td">
<div id="gh-shop">
<a id="gh-shop-a" _sp="m570.l3582" href="http://www.ebay.com/sch/allcategories/all-categories">Browse by<span id="gh-shop-e">category<i id="gh-shop-ei"></i></span></a>
</div>
</td>
<td class="gh-td-s">
<form action="http://www.ebay.com/sch/i.html" method="get" id="gh-f" class="lftd l-shad">
<input type="hidden" value="p2047675.m570.l1313" name="_trksid">
<table class="gh-tbl2">
<tbody>
<tr>
<td class="gh-td-s">
<div id="gh-ac-box">
<div id="gh-ac-box2">
<label class="gh-hdn g-hdn" for="gh-ac">
Enter your search keyword
</label>
<input autocomplete="off" name="_nkw" id="gh-ac" placeholder="I'm looking for... "
title="Enter your search keyword" maxlength="300" size="50" class="gh-tb ui-autocomplete-input"
type="text" role="textbox" aria-autocomplete="list" aria-haspopup="true">
</div>
</div>
</td>
<td class="gh-td">
<div id="gh-cat-box">
<select name="_sacat" id="gh-cat" size="1" class="gh-sb"...
JavaScript
var i = 100000;
var text = document.body.innerText || document.body.textContent;
var occurrences = function(string, subString, allowOverlapping) {
string += "";
subString += "";
if (subString.length <= 0) return string.length + 1;
var n = 0,
pos = 0;
var step = (allowOverlapping) ? (1) : (subString.length);
while (true) {
pos = string.indexOf(subString, pos);
if (pos >= 0) {
n++;
pos += step;
} else break;
}
return (n);
};
start = +new Date();
for ( j = i ; j > 0 ; --j ) {
text.match(/\$/g).length;
}
end = +new Date();
diff = end - start;
console.log(diff);
var start = +new Date();
for ( j = i ; j > 0 ; --j ) {
occurrences(text, '$');
}
var end = +new Date();
var diff = end - start;
console.log(diff);
start = +new Date();
for ( j = i ; j > 0 ; --j ) {
if (match = text.match(/\$/g)) {
match.length;
}
}
end = +new Date();
diff = end - start;
console.log(diff);