You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-9Lines changed: 10 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -31,32 +31,33 @@ JavaScript Cookie supports [npm](https://www.npmjs.com/package/js-cookie) under
31
31
$ npm install js-cookie --save
32
32
```
33
33
34
+
The npm package has a `module` property that is pointing to an ES module, to provide support for ES module aware bundlers.
35
+
34
36
### Direct download
35
37
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.
37
41
38
-
Example:
42
+
Example for how to load the ES module in a browser:
_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:
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.
0 commit comments