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 8632701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:23:17+00:00 2026-06-12T09:23:17+00:00

I’m upgrading an old classic ASP application using client-side VBScript to a more modern

  • 0

I’m upgrading an old classic ASP application using client-side VBScript to a more modern framework using jQuery. In this instance, my jQuery replacement is noticeably slower running in IE8 than the previous VBScript. Here is the script I am replacing:

Function Find()
  name = Ucase(MyForm.SearchBox.value)
  For x = 0 to MyForm.ComboBox.Length - 1
    If Ucase(Left(MyForm.ComboBox.options(x).text,len(name)))=name Then
      MyForm.ComboBox.options(x).Selected = True
      Exit Function
    End If
  Next
End Function 

Here is my replacement:

var text = $('#SearchBox').val();
$('#ComboBox option').each(function () {
  if ($(this).text().toUpperCase().indexOf(text.toUpperCase()) == 0) {
    $(this).prop('selected', true);
    return false;
  }
});

There is no delay / freeze at all running the VBScript. The user can type as fast as he wants and the search keeps up. On the same machine, with the same data, the jQuery solution has a very noticeable delay responding to text; it appears like the keyboard entry is frozen while the search is happening.

The ComboBox element is an HTML select with about 3,500 option elements. This method is firing on the keyup event of the search box.

What optimizations can I make so that this jQuery runs as fast as the old VBScript?

  • 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-06-12T09:23:18+00:00Added an answer on June 12, 2026 at 9:23 am

    I ended up implementing a binary search on the sorted options. I guess the jQuery engine is just not as efficient on IE8 vs. the VBScript engine on this type of search.

    var searchFoo = function(text) {
        var searchFor = text.toUpperCase();
        var options = $('#ComboBox > option');
    
        var low = 0;
        var mid;
        var high = options.length - 1;
        var target;
    
        while (low <= high) {
            mid = Math.ceil(low + (high - low) / 2);
            target =
              options.eq(mid).text().toUpperCase().substring(0, searchFor.length);
    
            if (searchFor < target) {
                high = mid - 1;
            } else if (searchFor > target) {
                low = mid + 1;
            } else {
                // We found an option that matches. We want the *first* option that
                // matches, so search up through the array while they still match.
                while (mid > 0) {
                    target =
                      options.eq(mid - 1).text().toUpperCase()
                             .substring(0, searchFor.length);
                    if (searchFor == target) {
                        mid--;
                    } else {
                        return options.eq(mid);
                    }
                }
                return options.eq(mid);
            }
        }
    
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.