Skip to content

Commit 77b4f32

Browse files
authored
NPM release
For NPM stuff
2 parents cf480c5 + 962a018 commit 77b4f32

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[![HitCount](http://hits.dwyl.io/willstocks-tech/dynamically-polyfill-a-script.svg)](http://hits.dwyl.io/willstocks-tech/dynamically-polyfill-a-script)
22
[![](https://data.jsdelivr.com/v1/package/gh/willstocks-tech/dynamically-polyfill-features-for-a-script/badge?style=rounded)](https://www.jsdelivr.com/package/gh/willstocks-tech/dynamically-polyfill-features-for-a-script)
3+
![npm](https://img.shields.io/npm/v/dynamic-polyfiller.svg)
34
![](https://img.shields.io/github/release/willstocks-tech/dynamically-polyfill-features-for-a-script.svg?label=latest%20release)
45
![](https://img.shields.io/github/release-pre/willstocks-tech/dynamically-polyfill-features-for-a-script.svg?label=latest%20beta)
6+
57
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/willstocks-tech/dynamically-polyfill-features-for-a-script/issues)
68
![](https://img.shields.io/github/languages/top/willstocks-tech/dynamically-polyfill-features-for-a-script.svg?label=javascript&logo=languages&colorB=f1e05a)
79
[![Maintainability](https://api.codeclimate.com/v1/badges/8d00c9006111c5360102/maintainability)](https://codeclimate.com/github/willstocks-tech/dynamically-polyfill-features-for-a-script/maintainability)
@@ -22,8 +24,25 @@ See [deployment](#deployment) for notes on how to deploy the project on a live s
2224
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/).
2325

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

dynamicpolyfill.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ function initialiseMyScript(functionToRunonLoad) {
127127
}
128128
}
129129
}
130+
131+
module.exports = dynamicPolyfill;

dynamicpolyfill.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "dynamic-polyfiller",
3+
"version": "0.0.9",
4+
"description": "A small, lightweight script to check for native browser feature support - only polyfill when necessary (using the polyfill.io service), no wasted requests on browsers that have native support!",
5+
"main": "dynamicpolyfill.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/willstocks-tech/dynamically-polyfill-features-for-a-script.git"
12+
},
13+
"keywords": [
14+
"polyfill",
15+
"dynamic",
16+
"polyfill.io",
17+
"javascript"
18+
],
19+
"author": "Will Stocks <will@willstocks.co.uk> (https://willstocks.co.uk)",
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/willstocks-tech/dynamically-polyfill-features-for-a-script/issues"
23+
},
24+
"homepage": "https://github.com/willstocks-tech/dynamically-polyfill-features-for-a-script#readme"
25+
}

0 commit comments

Comments
 (0)