Skip to content

Commit c498f78

Browse files
committed
Tweak installation instructions in readme
We're no longer encouraging including the source directly, since there are two variants now.
1 parent 18ed0fd commit c498f78

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,33 @@ JavaScript Cookie supports [npm](https://www.npmjs.com/package/js-cookie) under
3131
$ npm install js-cookie --save
3232
```
3333

34+
The npm package has a `module` property that is pointing to an ES module, to provide support for ES module aware bundlers.
35+
3436
### Direct download
3537

36-
The source comes as an ES module. If you download it [here](https://github.com/js-cookie/js-cookie/blob/latest/src/js.cookie.mjs) directly, you must include it as such.
38+
Starting with version 3 [releases](https://github.com/js-cookie/js-cookie/releases) are distributed with two variants of this library, an ES module as well as an UMD module.
39+
40+
Note the different extensions: `.mjs` denotes the ES module, whereas `.js` is the UMD one.
3741

38-
Example:
42+
Example for how to load the ES module in a browser:
3943

4044
```html
41-
<script type="module" src="./js.cookie.mjs"></script>
45+
<script type="module" src="/path/to/js.cookie.mjs"></script>
4246
<script type="module">
43-
import Cookies from './js.cookie.mjs'
47+
import Cookies from '/path/to/js.cookie.mjs'
4448
4549
Cookies.set('foo', 'bar')
4650
</script>
4751
```
4852

49-
_Not all browsers support ES modules natively yet_. For this reason the npm package/release
50-
comes with both an ES module as well as an UMD module variant. Include the module along
51-
with the fallback to account for this. You may want to load the nomodule script in a deferred
52-
fashion (modules are deferred by default):
53+
_Not all browsers support ES modules natively yet_. For this reason the npm package/release provides both the ES and UMD module variant and you may want to include the ES module along with the UMD fallback to account for this:
5354

5455
```html
5556
<script type="module" src="/path/to/js.cookie.mjs"></script>
5657
<script nomodule defer src="/path/to/js.cookie.js"></script>
5758
```
5859

59-
Note the different extensions: `.mjs` denotes an ES module.
60+
Here we're loading the nomodule script in a deferred fashion, because ES modules are deferred by default. This may not be strictly necessary depending on how you're using the library.
6061

6162
### CDN
6263

0 commit comments

Comments
 (0)