chosen-js vs select2 vs selectize
Legacy jQuery Dropdown Enhancements for Web Forms
chosen-jsselect2selectizeSimilar Packages:

Legacy jQuery Dropdown Enhancements for Web Forms

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.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
chosen-js72,73722,075-3118 years agoMIT
select2025,952846 kB175-MIT
selectize013,037-388 years agoApache-2.0

Legacy jQuery Dropdown Enhancements: chosen-js vs select2 vs selectize

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.

๐Ÿ› ๏ธ Initialization and Setup

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 and Filtering Behavior

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;
    };
  }
});

๐ŸŒ Loading Data: Static vs AJAX

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));
  }
});

๐Ÿท๏ธ Tagging and User Input

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
});

๐ŸŽจ Customization and Templating

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>";
    }
  }
});

โš ๏ธ Maintenance and Modern Compatibility

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.

๐Ÿ“Š Summary: Feature Matrix

Featurechosen-jsselect2selectize
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

๐Ÿ’ก The Big Picture

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.

How to Choose: chosen-js vs select2 vs selectize

  • chosen-js:

    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.

  • select2:

    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.

  • selectize:

    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.

README for chosen-js

Chosen

Chosen is a library for making long, unwieldy select boxes more user friendly.

  • jQuery support: 1.7+
  • Prototype support: 1.7+

For documentation, usage, and examples, see: http://harvesthq.github.io/chosen/

For downloads, see: https://github.com/harvesthq/chosen/releases/

Package managers

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.

Contributing to this project

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.

Chosen Credits