Skip to content

Commit a87436d

Browse files
authored
Add section for NPM installation instructions
1 parent 35de4fe commit a87436d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,25 @@ See [deployment](#deployment) for notes on how to deploy the project on a live s
2222
Make sure you know what features your script is reliant on and polyfill those not natively supported on the browsers you support (you can check https://caniuse.com/).
2323

2424
## Deployment
25-
26-
### Loading locally (recommended):
25+
26+
### Loading via NPM
27+
1. Run `npm i dynamic-polyfiller`
28+
1. Import in your app (example below for React):
29+
```js
30+
import React from 'react';
31+
import {render} from 'react-dom';
32+
33+
//The import below is the bit you need!
34+
import dynamicPolyfill from 'dynamic-polyfiller';
35+
36+
dynamicPolyfill(
37+
["IntersectionObserver", "Object.assign"],
38+
'https://cdn.jsdelivr.net/npm/quicklink@1.0.0/dist/quicklink.umd.js',
39+
'quicklink();'
40+
);
41+
```
42+
43+
### Loading locally (recommended as is easiest):
2744
1. Copy the contents of [dynamicpolyfill.js](https://github.com/willstocks-tech/dynamically-polyfill-features-for-a-script/blob/master/dynamicpolyfill.js)
2845
1. Paste it into your existing JS file(s)
2946
1. Add a new line after it and call `dynamicPolyfill();` _Note: Case-sensitive_

0 commit comments

Comments
 (0)