0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-14 02:24:00 +01:00
Bootstrap/site/content/docs/5.3/getting-started/download.md
2023-09-14 17:02:13 +03:00

6.6 KiB

layout title description group toc
docs Download Download Bootstrap to get the compiled CSS and JavaScript, source code, or include it with your favorite package managers like npm, RubyGems, and more. getting-started true

Compiled CSS and JS

Download ready-to-use compiled code for Bootstrap v{{< param current_version >}} to easily drop into your project, which includes:

  • Compiled and minified CSS bundles (see [CSS files comparison]({{< docsref "/getting-started/contents#css-files" >}}))
  • Compiled and minified JavaScript plugins (see [JS files comparison]({{< docsref "/getting-started/contents#js-files" >}}))

This doesn't include documentation, source files, or any optional JavaScript dependencies like Popper.

<a href="{{< param "download.dist" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download Bootstrap');">Download

Source files

Compile Bootstrap with your own asset pipeline by downloading our source Sass, JavaScript, and documentation files. This option requires some additional tooling:

  • [Sass compiler]({{< docsref "/getting-started/contribute#sass" >}}) for compiling Sass source files into CSS files
  • Autoprefixer for CSS vendor prefixing

Should you require our full set of [build tools]({{< docsref "/getting-started/contribute#tooling-setup" >}}), they are included for developing Bootstrap and its docs, but they're likely unsuitable for your own purposes.

<a href="{{< param "download.source" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download source');">Download source

Examples

If you want to download and examine our [examples]({{< docsref "/examples" >}}), you can grab the already built examples:

<a href="{{< param "download.dist_examples" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download Examples');">Download Examples

CDN via jsDelivr

Skip the download with jsDelivr to deliver cached version of Bootstrap's compiled CSS and JS to your project.

<link href="{{< param "cdn.css" >}}" rel="stylesheet" integrity="{{< param "cdn.css_hash" >}}" crossorigin="anonymous">
<script src="{{< param "cdn.js_bundle" >}}" integrity="{{< param "cdn.js_bundle_hash" >}}" crossorigin="anonymous"></script>

If you're using our compiled JavaScript and prefer to include Popper separately, add Popper before our JS, via a CDN preferably.

<script src="{{< param "cdn.popper" >}}" integrity="{{< param "cdn.popper_hash" >}}" crossorigin="anonymous"></script>
<script src="{{< param "cdn.js" >}}" integrity="{{< param "cdn.js_hash" >}}" crossorigin="anonymous"></script>

Alternative CDNs

We recommend jsDelivr and use it ourselves in our documentation. However, in some cases—like in some specific countries or environments—you may need to use other CDN providers like cdnjs or unpkg.

You'll find the same files on these CDN providers, albeit with different URLs. With cdnjs, you can use this direct Bootstrap package link to copy and paste ready-to-use HTML snippets for each dist file from any version of Bootstrap.

{{< callout warning>}} If the SRI hashes differ for a given file, you shouldn't use the files from that CDN, because it means that the file was modified by someone else. {{< /callout >}}

Note that you should compare same length hashes, e.g. sha384 with sha384, otherwise it's expected for them to be different. As such, you can use an online tool like SRI Hash Generator to make sure that the hashes are the same for a given file. Alternatively, assuming you have OpenSSL installed, you can achieve the same from the CLI, for example:

openssl dgst -sha384 -binary bootstrap.min.js | openssl base64 -A

Package managers

Pull in Bootstrap's source files into nearly any project with some of the most popular package managers. No matter the package manager, Bootstrap will require a [Sass compiler]({{< docsref "/getting-started/contribute#sass" >}}) and Autoprefixer for a setup that matches our official compiled versions.

npm

Install Bootstrap in your Node.js powered apps with the npm package:

npm install bootstrap@{{< param "current_version" >}}

const bootstrap = require('bootstrap') or import bootstrap from 'bootstrap' will load all of Bootstrap's plugins onto a bootstrap object. The bootstrap module itself exports all of our plugins. You can manually load Bootstrap's plugins individually by loading the /js/dist/*.js files under the package's top-level directory.

Bootstrap's package.json contains some additional metadata under the following keys:

  • sass - path to Bootstrap's main Sass source file
  • style - path to Bootstrap's non-minified CSS that's been compiled using the default settings (no customization)

{{< callout info >}} {{< partial "callouts/info-npm-starter.md" >}} {{< /callout >}}

yarn

Install Bootstrap in your Node.js powered apps with the yarn package:

yarn add bootstrap@{{< param "current_version" >}}

RubyGems

Install Bootstrap in your Ruby apps using Bundler (recommended) and RubyGems by adding the following line to your Gemfile:

gem 'bootstrap', '~> {{< param current_ruby_version >}}'

Alternatively, if you're not using Bundler, you can install the gem by running this command:

gem install bootstrap -v {{< param current_ruby_version >}}

See the gem's README for further details.

Composer

You can also install and manage Bootstrap's Sass and JavaScript using Composer:

composer require twbs/bootstrap:{{< param current_version >}}

NuGet

If you develop in .NET Framework, you can also install and manage Bootstrap's CSS or Sass and JavaScript using NuGet. Newer projects should use libman or another method as NuGet is designed for compiled code, not frontend assets.

Install-Package bootstrap
Install-Package bootstrap.sass