JSFiddle - React, Tailwind, and code Playground

HTML

<ul id="the_ul">

</ul>

JavaScript

// Create 5000 lis

var $the_ul = $('#the_ul');
var $new_ul = $('#the_ul').clone();

for(var i = 1; i <= 100000; i++){
    $new_ul.append($('<li class="li-' + i + '">foo ' + i + ' bar</li>')); 
}

$('#the_ul').replaceWith($new_ul);



// Filter lis to only show prime numbers

var $the_ul = $('#the_ul');
var $new_ul = $('#the_ul').clone();

$new_ul.children().each(function(){
    if(is_prime(parseInt(this.className.substr(3), 10)))
       this.style.display = '';
    else
       this.style.display = 'none';   
});
    
$('#the_ul').replaceWith($new_ul);
    



// Slow(ish) way to check if a number is prime
function is_prime(x){
    if(x !== x >>> 0)
        return false;        
    var sq = Math.floor(Math.sqrt(x));
    for(var i = 2; i <= sq; i++)
        if(x % i === 0)
            return false;
    return true;    
}