# select2/select2 architecture

> Architecture diagram of the GitHub repository select2/select2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/select2/select2
- Repository: https://github.com/select2/select2

## Overview

Select2 is a jQuery plugin that upgrades native select controls into searchable single- or multi-select interfaces. The user-facing path begins with the plugin creating a Select2 instance; users search or browse results, select items, and the control reflects the selection. Data can come from native options, JavaScript arrays, or remote AJAX, with tagging and paginated loading as important extensions. The graph preserves documented capabilities and major core modules; several internal connections are dashed because their wiring is not shown in the excerpts.

Main entry points: [`src/js/select2/core.js`](https://github.com/select2/select2/blob/develop/src/js/select2/core.js) (Select2 Core), [`src/js/select2/data/base.js`](https://github.com/select2/select2/blob/develop/src/js/select2/data/base.js) (Data Adapter), [`src/js/jquery.select2.js`](https://github.com/select2/select2/blob/develop/src/js/jquery.select2.js) (jQuery Plugin), [`src/js/select2/dropdown/search.js`](https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/search.js) (Dropdown Search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin and Core"]
  node_jquery["jQuery Plugin<br/>[jquery.select2.js]"]
  node_core["Select2 Core<br/>[core.js]"]
  node_defaults["Defaults<br/>[defaults.js]"]
  node_options["Option Parsing<br/>[options.js]"]
end

subgraph group_data["Data and Search"]
  node_dataadapter["Data Adapter<br/>[base.js]"]
  node_native["Native Select Data<br/>[select.js]"]
  node_array["Array Data<br/>[array.js]"]
  node_ajax["Remote AJAX<br/>[ajax.js]"]
  node_tagging["Tags and Tokens<br/>[tags.js]"]
  node_searchlimits["Search Limits"]
end

subgraph group_ui["Selection and Results"]
  node_selection["Selection Views<br/>[multiple.js]"]
  node_selectionsearch["Inline Search<br/>[search.js]"]
  node_dropdown["Dropdown Views<br/>[dropdown.js]"]
  node_dropdownsearch["Dropdown Search<br/>[search.js]"]
  node_results["Results List<br/>[results.js]"]
end

subgraph group_extensions["Extensions and Localization"]
  node_pagination["Infinite Scroll<br/>[infiniteScroll.js]"]
  node_attachbody["Body Attachment<br/>[attachBody.js]"]
  node_diacritics["Diacritic Mapping<br/>[diacritics.js]"]
  node_translations["Translations<br/>[translation.js]"]
  node_languages["Language Catalog"]
end

node_user(("Page User"))

node_user -.->|"invokes"| node_jquery
node_jquery -->|"creates instance"| node_core
node_jquery -->|"exposes defaults"| node_defaults
node_core -.->|"configures"| node_options
node_core -.->|"queries data"| node_dataadapter
node_dataadapter -.->|"uses native"| node_native
node_dataadapter -.->|"uses arrays"| node_array
node_dataadapter -.->|"uses remote"| node_ajax
node_selectionsearch -->|"emits query"| node_core
node_dropdownsearch -->|"emits query"| node_core
node_core -.->|"updates selection"| node_selection
node_core -.->|"opens dropdown"| node_dropdown
node_core -.->|"updates results"| node_results
node_tagging -.->|"decorates data"| node_dataadapter
node_searchlimits -.->|"limits queries"| node_dataadapter
node_pagination -.->|"loads pages"| node_ajax
node_dropdown -.->|"attaches to body"| node_attachbody
node_dropdownsearch -.->|"searches results"| node_results
node_core -.->|"configures language"| node_translations
node_translations -.->|"loads catalog"| node_languages
node_dataadapter -.->|"matches text"| node_diacritics

click node_jquery "https://github.com/select2/select2/blob/develop/src/js/jquery.select2.js"
click node_core "https://github.com/select2/select2/blob/develop/src/js/select2/core.js"
click node_defaults "https://github.com/select2/select2/blob/develop/src/js/select2/defaults.js"
click node_options "https://github.com/select2/select2/blob/develop/src/js/select2/options.js"
click node_dataadapter "https://github.com/select2/select2/blob/develop/src/js/select2/data/base.js"
click node_native "https://github.com/select2/select2/blob/develop/src/js/select2/data/select.js"
click node_array "https://github.com/select2/select2/blob/develop/src/js/select2/data/array.js"
click node_ajax "https://github.com/select2/select2/blob/develop/src/js/select2/data/ajax.js"
click node_tagging "https://github.com/select2/select2/blob/develop/src/js/select2/data/tags.js"
click node_searchlimits "https://github.com/select2/select2/blob/develop/src/js/select2/data/minimumInputLength.js"
click node_selection "https://github.com/select2/select2/blob/develop/src/js/select2/selection/multiple.js"
click node_selectionsearch "https://github.com/select2/select2/blob/develop/src/js/select2/selection/search.js"
click node_dropdown "https://github.com/select2/select2/blob/develop/src/js/select2/dropdown.js"
click node_dropdownsearch "https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/search.js"
click node_results "https://github.com/select2/select2/blob/develop/src/js/select2/results.js"
click node_pagination "https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/infiniteScroll.js"
click node_attachbody "https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/attachBody.js"
click node_diacritics "https://github.com/select2/select2/blob/develop/src/js/select2/diacritics.js"
click node_translations "https://github.com/select2/select2/blob/develop/src/js/select2/translation.js"
click node_languages "https://github.com/select2/select2/tree/develop/src/js/select2/i18n"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_jquery,node_core,node_defaults,node_options,node_user toneBlue
class node_dataadapter,node_native,node_array,node_ajax,node_tagging,node_searchlimits toneAmber
class node_selection,node_selectionsearch,node_dropdown,node_dropdownsearch,node_results toneMint
class node_pagination,node_attachbody,node_diacritics,node_translations,node_languages toneRose
```

## Components

### Plugin and Core

- [jQuery Plugin](https://github.com/select2/select2/blob/develop/src/js/jquery.select2.js): `src/js/jquery.select2.js`
- [Select2 Core](https://github.com/select2/select2/blob/develop/src/js/select2/core.js): `src/js/select2/core.js`
- [Defaults](https://github.com/select2/select2/blob/develop/src/js/select2/defaults.js): `src/js/select2/defaults.js`
- [Option Parsing](https://github.com/select2/select2/blob/develop/src/js/select2/options.js): `src/js/select2/options.js`

### Data and Search

- [Data Adapter](https://github.com/select2/select2/blob/develop/src/js/select2/data/base.js): `src/js/select2/data/base.js`
- [Native Select Data](https://github.com/select2/select2/blob/develop/src/js/select2/data/select.js): `src/js/select2/data/select.js`
- [Array Data](https://github.com/select2/select2/blob/develop/src/js/select2/data/array.js): `src/js/select2/data/array.js`
- [Remote AJAX](https://github.com/select2/select2/blob/develop/src/js/select2/data/ajax.js): `src/js/select2/data/ajax.js`
- [Tags and Tokens](https://github.com/select2/select2/blob/develop/src/js/select2/data/tags.js): `src/js/select2/data/tags.js`
- [Search Limits](https://github.com/select2/select2/blob/develop/src/js/select2/data/minimumInputLength.js): `src/js/select2/data/minimumInputLength.js`

### Selection and Results

- [Selection Views](https://github.com/select2/select2/blob/develop/src/js/select2/selection/multiple.js): `src/js/select2/selection/multiple.js`
- [Inline Search](https://github.com/select2/select2/blob/develop/src/js/select2/selection/search.js): `src/js/select2/selection/search.js`
- [Dropdown Views](https://github.com/select2/select2/blob/develop/src/js/select2/dropdown.js): `src/js/select2/dropdown.js`
- [Dropdown Search](https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/search.js): `src/js/select2/dropdown/search.js`
- [Results List](https://github.com/select2/select2/blob/develop/src/js/select2/results.js): `src/js/select2/results.js`

### Extensions and Localization

- [Infinite Scroll](https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/infiniteScroll.js): `src/js/select2/dropdown/infiniteScroll.js`
- [Body Attachment](https://github.com/select2/select2/blob/develop/src/js/select2/dropdown/attachBody.js): `src/js/select2/dropdown/attachBody.js`
- [Diacritic Mapping](https://github.com/select2/select2/blob/develop/src/js/select2/diacritics.js): `src/js/select2/diacritics.js`
- [Translations](https://github.com/select2/select2/blob/develop/src/js/select2/translation.js): `src/js/select2/translation.js`
- [Language Catalog](https://github.com/select2/select2/tree/develop/src/js/select2/i18n): `src/js/select2/i18n`

### Other components

- **Page User**

## Connections

- Page User → jQuery Plugin: invokes
- jQuery Plugin → Select2 Core: creates instance (evidence: `src/js/jquery.select2.js`)
- jQuery Plugin → Defaults: exposes defaults (evidence: `src/js/jquery.select2.js`)
- Select2 Core → Option Parsing: configures
- Select2 Core → Data Adapter: queries data
- Data Adapter → Native Select Data: uses native
- Data Adapter → Array Data: uses arrays
- Data Adapter → Remote AJAX: uses remote
- Inline Search → Select2 Core: emits query (evidence: `src/js/select2/selection/search.js`)
- Dropdown Search → Select2 Core: emits query (evidence: `src/js/select2/dropdown/search.js`)
- Select2 Core → Selection Views: updates selection
- Select2 Core → Dropdown Views: opens dropdown
- Select2 Core → Results List: updates results
- Tags and Tokens → Data Adapter: decorates data
- Search Limits → Data Adapter: limits queries
- Infinite Scroll → Remote AJAX: loads pages
- Dropdown Views → Body Attachment: attaches to body
- Dropdown Search → Results List: searches results
- Select2 Core → Translations: configures language
- Translations → Language Catalog: loads catalog
- Data Adapter → Diacritic Mapping: matches text
