What are the differences between Chosen and Select2? Ask Question

What are the differences between Chosen and Select2? Ask Question

Chosen and Select2 are the two more popular libraries for extending selectboxes.

Both seem to be actively maintained, Chosen is older and supports both jQuery and Prototype.

Select2 is jQuery only, its documentation says Select2 is inspired by Chosen, but doesn't detail any improvements made (if any) or other reasons for the rewrite.

Two libraries have pretty much same feature set, the only comparison I've found is a somewhat inconclusive jsperf test page.

Does any of these libraries have any advantages over the other?

ベストアンサー1

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.
  • 結果のページング: Select2 は大規模なデータセットで動作し、一度に少量の一致する結果のみを読み込むため、ページングをサポートする必要があります。Select2 は、ユーザーが現在読み込まれている結果セットの一番下までスクロールすると検索機能を呼び出し、結果の「無限スクロール」を可能にします。
  • 結果のカスタム マークアップ: タグでサポートされているマークアップはテキストのみであるため、Chosen ではテキスト結果のレンダリングのみがサポートされますoption。Select2 は、結果を表すあらゆる種類のマークアップを生成するために使用できる拡張ポイントを提供します。
  • 結果を即座に追加する機能: Select2 は、ユーザーが入力した検索用語から結果を追加する機能を提供し、タグ付けに使用できるようにします。

おすすめ記事