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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:48:19+00:00 2026-06-04T01:48:19+00:00

I have a Google Chrome extension that creates a select-all function for a search

  • 0

I have a Google Chrome extension that creates a select-all function for a search engine, but it is slow (1-14 seconds, 250-1000 results) is there a faster way to do this? My code is below:

var dropdownvalue = dropdown.options[dropdown.selectedIndex].value;
if ((dropdownvalue == "createFullCheckboxes") || (dropdownvalue == "createNameCheckboxes")) {
    var div_embed1 = document.getElementById('results-pane');

    if (div_embed1) {
        div_embed1.innerHTML = '<form id="checkbox-form">' + div_embed1.innerHTML + '</form>';
    }

    var i;
    var x = document.getElementsByClassName('name');

    for (i = 0; i < x.length; i++) {
        x[i].innerHTML = '<input id="checkbox" type="checkbox">' + x[i].innerHTML + '';
    }

    checkedAll();
    return;
}​

I tried changing the for loop to this: for (var i = 0, len = x.length; i < len; i++){ but there was only a 20ms difference. CheckedAll() is a function that simply selects all of the checkboxes.

The other part (not shown) that loops through the selected checkboxes and actually makes the select-all work is much faster at 92ms and even for 1000 results it is still fast.

Here is a snip from the chrome dev tools:

Snapshot of the timings

Thank you.

  • 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-04T01:48:20+00:00Added an answer on June 4, 2026 at 1:48 am

    I would test:

    var x = document.getElementsByClassName('name');
    var h = '<input class="checkbox" type="checkbox">';
    var i = x.length;
    while(i--){ x[i].innerHTML = h + x[i].innerHTML; }
    

    the equal test should be faster than the less than test.

    Try a Duffs Device:(speculative as we do not know the markup render and the prototype properties that might impact negatively)(NOTE removed the id= to avoid duplicate ID) replaced with class)

    function process(xi, h) {
        xi.innerHTML = h + xi.innerHTML;
    }
    var x = document.getElementsByClassName('name');
    var h = '<input class="checkbox" type="checkbox">';
    var iterations = Math.floor(x.length / 8);
    var leftover = x.length % 8;
    var i = 0;
    
    if (leftover > 0) {
        do {
            process(x[i++], h);
        } while (--leftover > 0);
    }
    
    do {
        process(x[i++], h);
        process(x[i++], h);
        process(x[i++], h);
        process(x[i++], h);
        process(x[i++], h);
        process(x[i++], h);
        process(x[i++], h);
        process(x[i++], h);
    } while (--iterations > 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While creating a Google Chrome extension, I have code that must remain in a
I have a Google Chrome extension that upon pressing a button executes an xmlhttp
I have written an extension in Google Chrome that opens a tab to a
I have created a simple Google chrome extension that overrides CSS classes using the
I have a Google Chrome extension that opens a Twitter Bootstrap dialog (using JQuery
I am making a Google Chrome extension and I would like to have my
At the moment I am developing a Google Chrome Extension in which I have
I am working on creating a Google Chrome extension. We have it included in
I am experiencing some problems with a google chrome extension I have made. I've
I'm working on a Google Chrome extension. In the popup I have the following

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.