I am trying to make my webpage load quicker and be more responsive. I am loading in upto 4k images that a user can scroll down through, apply filters to, and sort.
My filter usese the below code;
function filter(){
// NEED A WAY TO ADD MULTI FILTER HERE
var input, filter, span, txtValue, i, a;
input = document.getElementById('userFilter'); //usersinput
filter = input.value.toUpperCase(); //userinput capitalized
itemWrappers = document.getElementsByClassName('itemWrapperColumns');
for (i = 0; i < itemWrappers.length; i++){
a = itemWrappers[i];
txtValue = a.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
itemWrappers[i].style.display = ""; // refer to the comment on span - need to hide the item container, not the span
}else{
itemWrappers[i].style.display = "none";
}
}
}
This was working when I was displaying all images on a very long scroll bar. I then found a way to "hide" images until the user scrolls down, at which point the images render. I am using
content-visibility: auto;
for this.
But now I am using this, the filter dosnt quite work. It will still apply the filter to the items that are currently visible on the users screen, but to the items that have not been rendered yet, these do not appear.
The elements of the un-rendered items are still on the page as I can see this in the console.
I am not stuck on using content-visiblity, if someone has a way to make a page with thousands of images render quickly and I can use filters/sorts that would also work.
Thanks in advance.
Edit: for a bit more context, i am trying to hide my top level div wrapper that contains everything enter image description here