Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance degradation with over 20 selects on website #582

Closed
rangerek opened this issue Apr 29, 2014 · 10 comments
Closed

performance degradation with over 20 selects on website #582

rangerek opened this issue Apr 29, 2014 · 10 comments

Comments

@rangerek
Copy link

when inserting a lot of selects on one page webpage freezes with watchdog alerting about jQuery execution too long
I have already checked #291 and #447 but they are not relevant here
Here is the sample of the code that is repeated >100 times on the webpage (with different parameters):

<td><select class="selectpicker" name="ref[240][sub_class]">
<option value=0 selected="selected" >A</option>
<option value=1>B</option></select></td>
<td><select class="selectpicker" name="ref[265][sub_class]">
<option value=0>A</option>
<option value=1 selected="selected" >B</option></select></td>
@KpjComp
Copy link

KpjComp commented Apr 29, 2014

Have you also checked -> #578
As this will cause 100+ touchdown events, when only 1 is needed..

@rangerek
Copy link
Author

@KpjComp - checked ;) but didn't understand the fix - what should be put where ;)
"Placing this code were you have put your $(document).on('keydown') and .on('focusin.modal') seems to fix the problem.."

@KpjComp
Copy link

KpjComp commented Apr 30, 2014

Hi @rangerek

In unit "bootstrap-select.js" at about line 509 you should see something like ->

$('body').on('touchstart.dropdown', '.dropdown-menu', function(e) {
    e.stopPropagation();
});

Basically move this code to about line 977, so you should then have something like ->

.....
        maxOptions: false
    };

    $('body').on('touchstart.dropdown', '.dropdown-menu', function(e) {
        e.stopPropagation();
    }); //SAX moved

    $(document)
        .data('keycount', 0)
....

Basically this makes the event for touchstart.dropdown only get initialized once, while the code was in the init procedure this was getting executed for every SELECT you put on your page. IOW: if you had 100 SELECT's on the page, there would be 100 touchstart.dropdown events getting executed, not only would this cause slowdown, but memory consumption/leak too. And in chrome on my machine would end up killing the page.

@rangerek
Copy link
Author

unfortunatelly it didn't work
http://www.rangerek.pl/select/test.html
you can see that i'm using the modified version of JS and the test page with copy/pasted some selects just crashes.
Any ideas?

@KpjComp
Copy link

KpjComp commented Apr 30, 2014

Seems to work for me, it's a bit slow but does not crash..
It's taking about 17 seconds..

As an optimization idea if you set the display of the body to none while you init, and then reset to block when done I get it down to about 7 seconds. So you could try that..

@rangerek
Copy link
Author

rangerek commented May 5, 2014

sorry but this is still not good for me for a webpage that does purely nothing :( - then for such number of selects i will look for other solution - pity

@t0xicCode
Copy link
Collaborator

@KpjComp Could you make a PR out of this?

@benjaminrigaud
Copy link

I just got a similar problem: 14 seconds to load my page with 1.6.3.
6 seconds to load with 1.6.2.

@andyburton
Copy link

Likewise with 1.6.3 and 2.0.0-beta1 - had to revert to 1.6.2 to get it to work in IE8 without the dreaded "A script on this page is causing Internet Explorer to run slowly" alert.

caseyjhol added a commit that referenced this issue May 5, 2015
Utilizes native Javascript DOM properties to improve render speed. Moves
liHeight function inside setSize so it only runs when the select is
opened rather than running it for every select on init.
@caseyjhol
Copy link
Member

Please try v1.7.0-rc2 and report back.

avantika-gupta-jtg pushed a commit to JoshLabs/bootstrap-select that referenced this issue May 14, 2020
…appointments#582)

Utilizes native Javascript DOM properties to improve render speed. Moves
liHeight function inside setSize so it only runs when the select is
opened rather than running it for every select on init.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants