-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 issue loading page with large number of selectpickers with relatively large number of options #1665
Comments
Because we're on github with all of these PR things here's a PR with extracted changes from the archive :-) We've tried it on some of our pages (worst scenarios) where we have 540 bootstrap-select components with 35 options each. With the changes above Chrome browser spends in init() function ~3s while without those changes it takes ~10s according CPU profiling. |
Following changes are extracted from the archive provided in #1665
…lements Lazy loading (extracted changes from provided archive, see issue #1665)
could try lazy-loading #2187 |
… if necessary (selectedTextFormat is "values" or is "count" and the number selected is below the limit). #1665
Most of your enhancements have been addressed in one way or another in the latest release - v1.13.6. Using your slow.htm page but with the latest version results in the whole page being loaded in under half a second in Chrome 72. Thanks for your contribution! |
Summary: I am building a page that contains a large number of select elements (~200) each with a large number of options (~500). When using selectpicker for these elements the page has a very long load time and encounters the dreaded long running script warning on IE (performance is especially bad on IE). I made a few tweaks to reduce the load times and have attached the test with the tweaked code. Not sure if I have broken any functionality or overlooked any gotchas, but so far the changes seem to work correctly. I wanted to provide these changes to see if some variation could be incorporated into the project to provide similar performance improvement.
Environment details: I encountered the issue in chrome, firefox and IE. Performance is by far the worst in IE. You can see the versions of jquery, bootstrap, and bootstrap-select in the attached example.
I tried to add appropriate comments in the code to explain the changes, but here is a rough summary of the changes:
Instructions for running the test:
extract contents of the attached zip file
load slow.htm in your browser
press "Create Select Fields(native)" button. This will create 200 native select elements each with 500 options on the page
press "Selectpicker (orig)" button. This will change the native selects into selectpickers using the original implementation and report the run time.
press reset (or refresh the page)
press "Create Select Fields(native)" button. This will create 200 native select elements each with 500 options on the page
press "Selectpicker(+perf changes)" button. This will change the native selects into selectpickers using the performance tweaks described above and report the run time.
In my testing, I was seeing around an 80% improvement on chrome and around a 95% improvement on IE.
selectpicker.zip
The text was updated successfully, but these errors were encountered: