Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6230063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:40:50+00:00 2026-05-24T09:40:50+00:00

In the code below, friendBlocks has 800+ items that look like this: <div class=’block’>

  • 0

In the code below, friendBlocks has 800+ items that look like this:

<div class='block'>
    <span class='title'>Some Name</span>
    <img src='some.img' />
</div>

And I’m trying to filter them with the below code. It works, but is extremely slow and sometimes crashes the browser.

friendBlocks = friendform.find('.block');
filterFriends = function(text) {
    friendBlocks.each(function() {
        var block;
        block = $(this);
        if (block.children('.title').text().toLowerCase().indexOf(text) >= 0) {
            block.show();
        } else {
            block.hide();
        }
    });
};

Is there some way to optimize this and do the search more efficiently?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:40:53+00:00Added an answer on May 24, 2026 at 9:40 am

    Do not apply the manipulation on each item in real-time! Clone the node, that contains the block divs, perform the operation, and then replace the original DOM.

    Something like (not tested, just example):

    friendform   = $('#container').clone();
    friendBlocks = friendform.find('.block');
    filterFriends = function(text) {
        friendBlocks.each(function() {
            var block;
            block = $(this);
            if (block.children('.title').text().toLowerCase().indexOf(text) >= 0) {
                block.show();
            } else {
                block.hide();
            }
        });
    };
    $('#container').replaceWith(friendform);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

code below. i'm tryind to obtain string answers like a1, c4 this is what
Code below defines a ChargeCustomer class that contains an array of type customers. I
Code below is pseudo code. Imagine a class Fruit which has a factory method
The code below shows a sample that I've used recently to explain the different
The code below gives me this mysterious error, and i cannot fathom it. I
Code below is a simple c# function return an int array. I would like
Code below select the <td> in which I'd like to select an <a> tag.
Code below is working well as long as I have class ClassSameAssembly in same
see code below.. <div style=overflow:auto;width:250px;height:75px;border:1px solid #336699;padding-left:5px> <label style={width:250px;}><input type=checkbox name=wow[] onclick='highlight_div(this);'> PHP</label><br> <label
The code below is incorrect but the idea here is that I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.