Select2 gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options.
Chosen is a JavaScript plugin that makes select boxes user-friendly. It is currently available in both jQuery and Prototype flavors.
As of Select2 3.3.1, below are what's documented in its README.md
What Does Select2 Support That Chosen Does Not?
- Working with large datasets: Chosen requires the entire dataset to be loaded as
option
tags in the DOM, which limits it to working with small-ish datasets. Select2 uses a function to find results on-the-fly, which allows it to partially load results.- Paging of results: Since Select2 works with large datasets and only loads a small amount of matching results at a time it has to support paging. Select2 will call the search function when the user scrolls to the bottom of currently loaded result set allowing for the 'infinite scrolling' of results.
- Custom markup for results: Chosen only supports rendering text results because that is the only markup supported by
option
tags. Select2 provides an extension point which can be used to produce any kind of markup to represent results.- Ability to add results on the fly: Select2 provides the ability to add results from the search term entered by the user, which allows it to be used for tagging.
IMHO Chosen is "maintained" but not "actively maintained". 341 issues and 51 pull requests for Chosen. Select2 has 128 issues and 25 pull requests. I think the pattern for these is basically
Whichever one you pick, if your use case is exactly in their sweet spot, either one will work. If not, you'll eventually have to write your own or heavily customize these. In either case, the choice of which one specifically isn't all that important. I guess I'll side with @Andy Ray and @paul here that Select2 is probably the better initial choice.
Another difference worth mentioning is that Chosen
is developed in Sass
and CoffeeScript
whereas Select2
is plain CSS
and JS
. It is my personal option that Sass
and CoffeeScript
are unneeded layers of complexity which make debugging difficult.
After trying both I have decided to use neither - trying to get Select2
create item functionality turns out to be a very hairy affair as you simply can not do it when attached to <select>
elements - it just didn't feel well thought out the hoops I would have to jump through.
I have settled on using selectize.js which just adds the new <option>...</option>
element to the form's DOM - and that is sane. It does also use LESS
- but I would bypass that and just tailor the compiled CSS
directly in your project.
ps. I will try to update this answer when I find out more about the missing points
First, Let me tell you that Chosen and Select2 are two great plugin and this is my personal experience about Chosen. All what they are saying is true concerning Chosen.
The issue pointed by Pēteris Caune with the select
is 2 years old and still there is no official fix.
There is simply no good documentation for the API. It has been pointed out (watch issue 671) many time but there is still nothing.
It took them almost 2 years to solve this issue where chosen would basically not work if you hid the div with overflow:hidden
before showing it (and you have to use a witdh:X%
option that you would basically never know if you don't look for the issue).
I'd say that the main problem is the fix speed like said DelvarWorld in issue 92:
My pull request fixes this issue, but like my other one and many of the ones for chosen they are being ignored. This project has too many contributors with too small of a code base.
I first picked Chosen for its MIT licence but I had all theses issues (dropdown cut, not finding the API, looking for hours for the overflow hidden), so I decided to switch to select2 because it has a better documentation, no dropdown cut bug and faster fixes.
One feature that works in Select2 but doesn't work in Chosen, is select
inside element that has overflow: hidden
or overflow: auto
.
Corresponding issue for Chosen: https://github.com/harvesthq/chosen/issues/86
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With