Skip to content

Commit e0ccc93

Browse files
committed
More guidance of installing and using in browsers
1 parent de79f09 commit e0ccc93

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ For more detail please visit:
1515

1616
## Usage
1717

18-
To install this library as a dependency in another project:
19-
`npm install --save node-diff3`
18+
To install node-diff3 as a dependency in another project:
19+
```bash
20+
$ npm install --save node-diff3
21+
```
2022

21-
This library is distributed in both UMD and ES6 module formats. ([read more](https://dev.to/iggredible/what-the-heck-are-cjs-amd-umd-and-esm-ikm))
23+
This library is distributed in both UMD and ES6 module formats for maxmimum compatibility. <sub>([read more about Javascript module formats](https://dev.to/iggredible/what-the-heck-are-cjs-amd-umd-and-esm-ikm))</sub>
2224
* `index.mjs` - ES6 module
2325
* `dist/index.js` - UMD module, ES6 syntax
2426
* `dist/index.es5.js` - UMD module, ES5 syntax
@@ -33,14 +35,19 @@ import * as Diff3 from 'node-diff3'; // ES6 import all
3335
import { diff3Merge } from 'node-diff3'; // ES6 import named
3436
```
3537

36-
You can also use UMD builds of node-diff3 directly in a web browser. A good way to do this is to fetch the file from the [jsDelivr CDN](https://www.jsdelivr.com/):
38+
You can also use node-diff3 directly in a web browser. A good way to do this is to fetch the file from the [jsDelivr CDN](https://www.jsdelivr.com/), which can even deliver minified versions:
39+
40+
The latest versions of many web browsers now support [ES6 modules in script tags](https://caniuse.com/#feat=es6-module) like this:
41+
```html
42+
<script type="module" src="https://cdn.jsdelivr.net/npm/node-diff3@2/index.min.mjs"></script>
43+
```
3744

38-
For modern ES6-capable browsers:
45+
Older versions of modern ES6-capable browsers can still load the UMD build:
3946
```html
4047
<script src="https://cdn.jsdelivr.net/npm/node-diff3@2/dist/index.min.js"></script>
4148
```
4249

43-
Or if you need to support older browsers like Internet Explorer, fetch the ES5 version:
50+
Or if you need to support even older browsers like Internet Explorer, fetch the ES5 version:
4451
```html
4552
<script src="https://cdn.jsdelivr.net/npm/node-diff3@2/dist/index.es5.min.js"></script>
4653
```

0 commit comments

Comments
 (0)