Skip to content

Commit b7a389f

Browse files
authored
Merge pull request #89 from launchdarkly/ag/ch22054/readme-polyfills
[ch22054] Document the Promise polyfill and make all polyfill sections consistent
2 parents 22491fd + af2103c commit b7a389f

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

README.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,62 @@ when `client.on('change')` is called.
2828
### EventSource polyfill
2929

3030
If you need streaming support, and you wish to support browsers that do not
31-
support `EventSource` natively, you can install a polyfill, such as
31+
support `EventSource` natively, you can install a polyfill such as
3232
[EventSource](https://github.com/Yaffle/EventSource).
3333

34-
You can load the polyfill via a script tag in the `<head>` before the script
35-
where you initialize `LDClient`:
34+
#### CDN
3635

37-
<script src="/public/eventsource.js"></script>
36+
You can load the polyfill via a script tag in the `<head>` before the script where you initialize `LDClient`:
3837

39-
If you use [webpack](https://webpack.github.io/) or
40-
[browserify](http://browserify.org/), make sure to require the polyfill before
41-
`LDClient` is initialized.
38+
<script src="https://unpkg.com/[email protected]/src/eventsource.min.js"></script>
39+
40+
#### NPM or Yarn
41+
42+
npm install [email protected]
43+
44+
Then import it before the module that initializes the LaunchDarkly client:
45+
46+
require('event-source-polyfill');
4247

4348
### Document.querySelectorAll() polyfill
4449

4550
If you need to run A/B tests on IE7 or IE8 you will need to install a polyfill
4651
for `document.querySelector()` such as
4752
[polyfill-queryselector](https://github.com/cobbdb/polyfill-queryselector).
4853

49-
You can load the polyfll via a script tag in the `<head>`:
54+
#### CDN
55+
56+
You can load the polyfill via a script tag in the `<head>` before the script where you initialize `LDClient`:
57+
58+
<script src="https://unpkg.com/[email protected]/querySelector.js"></script>
59+
60+
#### NPM or Yarn
61+
62+
npm install [email protected]
63+
64+
Then import it before the module that initializes the LaunchDarkly client:
65+
66+
require('polyfill-queryselector');
67+
68+
### Promise polyfill
69+
70+
The newer versions of the use `Promise`. If you need to support older browsers, you will
71+
need to install a polyfill for it, such as [es6-promise](https://github.com/stefanpenner/es6-promise).
72+
73+
#### CDN
74+
75+
You can load the polyfill via a script tag in the `<head>` before the script where you initialize `LDClient`:
76+
77+
<script src="https://unpkg.com/[email protected]/dist/es6-promise.auto.min.js"></script>
78+
79+
#### NPM or Yarn
80+
81+
npm install [email protected]
82+
83+
Then import it before the module that initializes the LaunchDarkly client:
5084

51-
<script src="/public/querySelector.js"></script>
85+
require('es6-promise/auto');
5286

53-
You can also install it with `npm install polyfill-queryselector` or `bower install polyfill-queryselector`.
5487

5588
## Installation
5689

0 commit comments

Comments
 (0)