1
0
mirror of synced 2024-11-25 06:16:08 +03:00
select2/docs/pages/01.getting-started/01.installation/docs.md

51 lines
2.2 KiB
Markdown
Raw Normal View History

2017-09-03 03:34:47 +03:00
---
title: Installation
taxonomy:
category: docs
---
2017-10-12 05:31:42 +03:00
In order to use Select2, you must include the compiled JavaScript and CSS files on your website. There are multiple options for including these pre-compiled files, also known as a **distribution**, in your website or application.
2017-09-03 03:34:47 +03:00
## Using Select2 from a CDN
2017-10-12 05:31:42 +03:00
A CDN (content delivery network) is the fastest way to get up and running with Select2!
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
Select2 is hosted on both the [cdnjs](https://cdnjs.com/libraries/select2) and [jsDelivr](https://www.jsdelivr.com/#!select2) CDNs. Simply include the following lines of code in the `<head>` section of your page:
2017-09-03 03:34:47 +03:00
```
2019-08-29 04:26:12 +03:00
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/js/select2.min.js"></script>
2017-09-03 03:34:47 +03:00
```
2017-10-12 05:31:42 +03:00
>>> <i class="fa fa-info-circle"></i> Immediately following a new release, it takes some time for CDNs to catch up and get the new versions live on the CDN.
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
## Installing with Bower
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
Select2 is available on Bower. Add the following to your `bower.json` file and then run `bower install`:
2017-09-03 03:34:47 +03:00
```
2017-10-12 05:31:42 +03:00
"dependencies": {
"select2": "~4.0"
}
2017-09-03 03:34:47 +03:00
```
2017-10-12 05:31:42 +03:00
Or, run `bower install select2` from your project directory.
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
The precompiled distribution files will be available in `vendor/select2/dist/css/` and `vendor/select2/dist/js/`, relative to your project directory. Include them in your page:
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
```
<link href="vendor/select2/dist/css/select2.min.css" rel="stylesheet" />
<script src="vendor/select2/dist/js/select2.min.js"></script>
```
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
## Manual installation
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
We strongly recommend that you use either a CDN or a package manager like Bower or npm. This will make it easier for you to deploy your project in different environments, and easily update Select2 when new versions are released. Nonetheless if you prefer to integrate Select2 into your project manually, you can [download the release of your choice](https://github.com/select2/select2/tags) from GitHub and copy the files from the `dist` directory into your project.
2017-09-03 03:34:47 +03:00
2017-10-12 05:31:42 +03:00
Include the compiled files in your page:
2017-09-03 03:34:47 +03:00
```
<link href="path/to/select2.min.css" rel="stylesheet" />
<script src="path/to/select2.min.js"></script>
```