Skip to content

Commit ba9caac

Browse files
Johann-SXhmikosR
authored andcommitted
add docs about how to use the esm version
1 parent e8684b5 commit ba9caac

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

site/docs/4.3/getting-started/contents.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ bootstrap/
3232
├── bootstrap.bundle.js.map
3333
├── bootstrap.bundle.min.js
3434
├── bootstrap.bundle.min.js.map
35+
├── bootstrap.esm.js
36+
├── bootstrap.esm.js.map
37+
├── bootstrap.esm.min.js
38+
├── bootstrap.esm.min.js.map
3539
├── bootstrap.js
3640
├── bootstrap.js.map
3741
├── bootstrap.min.js

site/docs/4.3/getting-started/introduction.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Many of our components require the use of JavaScript to function. Specifically,
3333
<script src="{{ site.cdn.js }}" integrity="{{ site.cdn.js_hash }}" crossorigin="anonymous"></script>
3434
{% endhighlight %}
3535

36+
If you use `<script type="module">`, please refer to our [using Bootstrap as a module]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#using-bootstrap-as-a-module) section.
37+
3638
Curious which components explicitly require our JavaScript and Popper.js? Click the show components link below. If you're at all unsure about the general page structure, keep reading for an example page template.
3739

3840
Our `bootstrap.bundle.js` and `bootstrap.bundle.min.js` include [Popper](https://popper.js.org/). For more information about what's included in Bootstrap, please see our [contents]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/contents/#precompiled-bootstrap) section.

site/docs/4.3/getting-started/javascript.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ Plugins can be included individually (using Bootstrap's individual `js/dist/*.js
1212

1313
If you use a bundler (Webpack, Rollup...), you can use `/js/dist/*.js` files which are UMD ready.
1414

15+
## Using Bootstrap as a module
16+
17+
We provide a version of Bootstrap built as `ESM` (`bootstrap.esm.js` and `bootstrap.esm.min.js`) which allows you to use Bootstrap as a module in your browser, if your [targeted browsers support it](https://caniuse.com/#feat=es6-module).
18+
19+
{% highlight html %}
20+
<script type="module">
21+
import { Toast } from 'bootstrap.esm.min.js'
22+
23+
Array.from(document.querySelectorAll('.toast'))
24+
.forEach(toastNode => new Toast(toastNode))
25+
</script>
26+
{% endhighlight %}
27+
28+
{% capture callout %}
29+
## Incompatible plugins
30+
31+
Due to browser limitations, some of our plugins, namely Dropdown, Tooltip and Popover plugins, cannot be used in a `<script>` tag with `module` type because they depend on Popper.js. For more information about the issue see [here](https://developers.google.com/web/fundamentals/primers/modules#specifiers).
32+
{% endcapture %}
33+
{% include callout.html content=callout type="warning" %}
34+
1535
## Dependencies
1636

1737
Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs.

0 commit comments

Comments
 (0)