Home > Blockchain >  How to speed up Javascript page loading
How to speed up Javascript page loading

Time:08-10

I have figured out how to make my page work the way I want it to, but now the problem is my last blurb of JavaScript is making it take very long to load. All it does is hide duplicate rows. I cannot delete them.

Which is quite large. Everything runs very smoothly until this blurb of js. I am not too familiar with any front end, so I might be missing some little aspect. Right now the js sits at the bottom of my HTML code.

var arr = $("#fungi tr");

$.each(arr, function(i, item) {
  var currIndex = $("#fungi tr").eq(i);
  var matchText = currIndex.children("td").eq(1).text();
  $(this).nextAll().each(function(i, inItem) {
    if (matchText === $(this).children("td").eq(1).text()) {
      $(this).hide();
    }
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<table id="fungi" border="1" >
  <thead>
    <tr style="text-align: right;">
      <th>Family Name</th>
      <th>Genus Name</th>
      <th>Spore Print Colour Description</th>
      <th>Spore Print Colour 1</th>
      <th>Spore Print Colour 2</th>
      <th>Habitat</th>
      <th>Habitat Description</th>
      <th>Ecology</th>
      <th>Size</th>
      <th>Unique Cap Features</th>
      <th>Cap Description</th>
      <th>Partial Veil</th>
      <th>Gill Description</th>
      <th>Gill Attachement</th>
      <th>Unique Stipe Features</th>
      <th>Stipe Description</th>
      <th>Additional Features of Note</th>
      <th>Similar Genera / Look-alikes</th>
      <th>Additional Information</th>
      <th>Top Five NE Species</th>
      <th>Species to Species Identification Difficulty</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
  </tbody>
</table>

CodePudding user response:

This is faster and simpler if you MUST do this on the client

Vanilla JS - notice the swap of i and item and not much else

const arr = document.querySelectorAll("#fungi tbody tr");
arr.forEach((item,i) => {
  if (i<1) return;  
  const text = item.querySelector("td:nth-child(1)").textContent;
  item.hidden = text === arr[i-1].querySelector("td:nth-child(1)").textContent;
});

jQuery

const $arr = $("#fungi tbody tr");
$arr.each(function(i, item) {
  if (i<1) return;  
  const text = $("td:nth-child(1)",this).text()
  this.hidden = text === $arr.eq(i-1).find(":nth-child(1)").text()
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<table id="fungi" border="1" >
  <thead>
    <tr style="text-align: right;">
      <th>Family Name</th>
      <th>Genus Name</th>
      <th>Spore Print Colour Description</th>
      <th>Spore Print Colour 1</th>
      <th>Spore Print Colour 2</th>
      <th>Habitat</th>
      <th>Habitat Description</th>
      <th>Ecology</th>
      <th>Size</th>
      <th>Unique Cap Features</th>
      <th>Cap Description</th>
      <th>Partial Veil</th>
      <th>Gill Description</th>
      <th>Gill Attachement</th>
      <th>Unique Stipe Features</th>
      <th>Stipe Description</th>
      <th>Additional Features of Note</th>
      <th>Similar Genera / Look-alikes</th>
      <th>Additional Information</th>
      <th>Top Five NE Species</th>
      <th>Species to Species Identification Difficulty</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Free</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Fibrous</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >Scaly</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >Hollow</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
    <tr>
      <td>Agaricaceae</td>
      <td>Agaricus sp.</td>
      <td>Chocolate-Brown / Purple-Brown</td>
      <td >Brown</td>
      <td >Chocolate-Brown</td>
      <td >Ground</td>
      <td>Ground | Various. Roadsides, Grass, Meadows, Woodland... etc.</td>
      <td>Saprobic</td>
      <td >Medium</td>
      <td >None</td>
      <td>Fibrous / Scaly / None | Glabrous or with flattened fibers, not brightly coloured. Fleshy</td>
      <td >Yes</td>
      <td>Free / Barely Attached | Remote from stem. Pink when young. Dark brown and free or almost free at maturity. Close / Crowded</td>
      <td >Barely Attached</td>
      <td >None</td>
      <td>Hollow / None | n/a</td>
      <td>Medium / Large | Veil: Yes | Flesh thick, white. Usually white / gray / brown. Flesh, cap margin, base of stipe can often bruise yellow / red.</td>
      <td>Agrocybe are smaller and don't always have a partial veil.</td>
      <td>Chemical Reactions: KOH- negative or yellow-orange</td>
      <td>Agaricus bitorquis, Agaricus arvensis, Agaricus campestris, Agaricus nanaugustus, Agaricus xanthodermus</td>
      <td>Contains many species. Some are easy, some are extremely difficult.</td>
    </tr>
  </tbody>
</table>

CodePudding user response:

I can suggest a small improve, instead of checking every element with every other element just check every element with the elements bellow and only if they are not already hideen.

$.each(arr, function(i, item) {
    const matchText = item.children("td").eq(1).text();
    if(!item.is(":hidden")){
        $.each(arr, function(j, inItem) {
            if(i<j && matchText===inItem.children("td").eq(1).text()) {
                $(this).hide();
            }
        });
    }
});
  • Related