chosen-js, select2, and selectize are jQuery-based plugins designed to enhance standard HTML <select> elements with search, multi-select, and tagging capabilities. chosen-js is a maintained fork of the original Chosen library, focusing on simplicity and basic search. select2 is a robust, feature-rich solution often used for complex data loading and AJAX integration. selectize offers a hybrid input/select interface, excelling at tagging and custom option creation. All three rely on jQuery and direct DOM manipulation, making them legacy choices in modern component-driven frameworks.
In the era before React and Vue dominated the frontend, enhancing HTML <select> elements was a common pain point. chosen-js, select2, and selectize emerged as the standard solutions to add search, multi-select, and tagging features. While modern architecture favors headless UI components, understanding these libraries is crucial for maintaining legacy systems or working within jQuery-based workflows. Let's compare how they handle initialization, data, and customization.
All three libraries require jQuery and attach to existing <select> elements. However, their setup complexity varies.
chosen-js is the simplest to set up. It works almost immediately after including the script and CSS.
// chosen-js: Basic initialization
$(".my-select").chosen({
width: "100%"
});
select2 requires a bit more configuration but offers more hooks out of the box.
// select2: Basic initialization
$(".my-select").select2({
theme: "default",
width: "resolve"
});
selectize often requires defining options explicitly if not reading from DOM, and setup is slightly more verbose.
// selectize: Basic initialization
$(".my-select").selectize({
plugins: ["drag_drop", "remove_button"]
});
Search functionality is the primary reason developers adopt these libraries. Each handles text matching differently.
chosen-js provides basic text matching. It searches the visible text of options but lacks fuzzy search or complex filtering logic.
// chosen-js: Search config
$(".my-select").chosen({
disable_search_threshold: 10, // Hide search if less than 10 items
no_results_text: "No results found"
});
select2 offers advanced matching and allows custom matchers for fuzzy search or acronym matching.
// select2: Custom matcher
$(".my-select").select2({
matcher: function(params, data) {
if ($.trim(params.term) === "") return data;
if (data.text.toLowerCase().indexOf(params.term.toLowerCase()) > -1) return data;
return null;
}
});
selectize treats the input as a true text field, allowing for regex-based filtering and real-time scoring.
// selectize: Score-based search
$(".my-select").selectize({
score: function(search) {
return function(item) {
return item.text.indexOf(search) !== -1 ? 1 : 0;
};
}
});
Handling large datasets requires loading options dynamically. This is where the libraries diverge significantly.
chosen-js does not support AJAX loading natively. You must manually append <option> tags to the DOM and trigger an update event.
// chosen-js: Manual AJAX update
$.get("/api/options", function(data) {
var select = $(".my-select");
data.forEach(function(opt) {
select.append(new Option(opt.label, opt.value));
});
select.trigger("chosen:updated");
});
select2 has built-in AJAX support, making it the strongest choice for server-side data.
// select2: Built-in AJAX
$(".my-select").select2({
ajax: {
url: "/api/options",
dataType: "json",
data: function(params) {
return { q: params.term };
}
}
});
selectize also supports AJAX via a load callback, giving you control over when data is fetched (e.g., on focus or type).
// selectize: Load callback
$(".my-select").selectize({
load: function(query, callback) {
fetch("/api/options?q=" + query)
.then(res => res.json())
.then(data => callback(data));
}
});
Allowing users to create their own options (tagging) is a common requirement for flexible forms.
chosen-js does not support tagging or creating new options. It is strictly for selecting existing values.
// chosen-js: No tagging support
// Developers must manually add options to DOM before initialization
select2 supports tagging via a simple flag, allowing users to type new values that get added to the list.
// select2: Enable tagging
$(".my-select").select2({
tags: true,
tokenSeparators: [",", " "]
});
selectize was built with tagging in mind. It offers the most control over how new items are created and validated.
// selectize: Advanced tagging
$(".my-select").selectize({
create: function(input) {
return { value: input, text: input };
},
createOnBlur: true
});
Designing custom dropdown items (e.g., adding images or descriptions) requires templating support.
chosen-js has very limited templating. You generally have to inject HTML into the <option> text, which can be brittle.
// chosen-js: Limited HTML support
// <option data-custom="<img src='...'>">Label</option>
// Requires custom CSS to render correctly
select2 provides dedicated template callbacks for formatting results and selections.
// select2: Templates
$(".my-select").select2({
templateResult: function(data) {
return $("<span><img src='" + data.image + "'> " + data.text + "</span>");
}
});
selectize uses a plugin system and render methods to define custom HTML structures for items.
// selectize: Render methods
$(".my-select").selectize({
render: {
item: function(data, escape) {
return "<div class='item'><img src='" + escape(data.image) + "'></div>";
}
}
});
All three libraries share a critical architectural limitation: they depend on jQuery and manipulate the DOM directly. This conflicts with modern Virtual DOM libraries like React or Vue.
chosen-js: This is a fork of the original chosen library, which is deprecated. chosen-js receives occasional maintenance but is effectively in legacy mode. It should not be used for new greenfield projects.select2: Still actively maintained but heavily tied to jQuery. It is the most robust of the three for complex legacy enterprise apps but adds significant bundle weight.selectize: The original selectize package on npm is less maintained than the selectize.js fork. Both face challenges in modern build environments due to jQuery dependencies.| Feature | chosen-js | select2 | selectize |
|---|---|---|---|
| jQuery Required | โ Yes | โ Yes | โ Yes |
| AJAX Support | โ Manual | โ Built-in | โ Callback |
| Tagging | โ No | โ Yes | โ Advanced |
| Templating | โ ๏ธ Limited | โ Robust | โ Flexible |
| Bundle Weight | ๐ข Light | ๐ด Heavy | ๐ก Medium |
| Active Maintenance | โ ๏ธ Low | ๐ข High | ๐ก Moderate |
chosen-js is the lightweight option for simple search needs in older projects. Use it only if you need a quick fix for a basic <select> element without AJAX or tagging.
select2 is the workhorse for enterprise jQuery applications. If you need to load data from an API or handle complex selection logic, this is the most stable choice among the three.
selectize is the specialist for tagging and user-generated content. Choose this if the UI needs to feel more like an input field than a dropdown list.
Final Thought: In 2024 and beyond, avoid these libraries for new development. Modern frameworks offer better alternatives like react-select, Vue Multiselect, or headless UI libraries that do not require jQuery. Reserve chosen-js, select2, and selectize for maintaining existing legacy systems where rewriting the form layer is not feasible.
Choose chosen-js if you need a lightweight, drop-in replacement for standard selects with basic search functionality in a legacy jQuery codebase. It is suitable for simple forms where you do not need AJAX data loading or complex tagging features. Avoid this for new projects, as it lacks modern framework integration and relies on jQuery.
Choose select2 if you require robust AJAX support, complex data formatting, or extensive configuration options within a jQuery environment. It is ideal for admin panels or enterprise apps where users need to search large datasets loaded from a server. Be aware that it is heavy and requires jQuery, which may conflict with modern build pipelines.
Choose selectize if your use case involves tagging, creating new options on the fly, or a hybrid input/dropdown experience. It provides the most flexible UI for user-generated content but comes with a steeper learning curve for customization. Like the others, it depends on jQuery and is best reserved for maintaining existing systems rather than starting new ones.
Chosen is a library for making long, unwieldy select boxes more user friendly.
For documentation, usage, and examples, see: http://harvesthq.github.io/chosen/
For downloads, see: https://github.com/harvesthq/chosen/releases/
Chosen is available through Bower, npm, and Composer, however, the package names are not the same.
To install with Bower:
bower install chosen
To install with npm:
npm install chosen-js
To install with Composer:
composer require harvesthq/chosen
The compiled files for these packages are automatically generated and stored in a 2nd Chosen repository. No pull requests will be accepted to that repository.
We welcome all to participate in making Chosen the best software it can be. The repository is maintained by only a few people, but has accepted contributions from over 50 authors after reviewing hundreds of pull requests related to thousands of issues. You can help reduce the maintainers' workload (and increase your chance of having an accepted contribution to Chosen) by following the guidelines for contributing.