Skip to content

Commit ee140a9

Browse files
committed
revisit load and es6 import
1 parent cbf9389 commit ee140a9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Plotly.js can be used to produce dozens of chart types and visualizations, inclu
2121
* [Load as a node module](#load-as-a-node-module)
2222
* [Load via script tag](#load-via-script-tag)
2323
* [Bundles](#bundles)
24-
* [Alternative ways to require or build plotly.js](#alternative-ways-to-require-or-build-plotlyjs)
24+
* [Alternative ways to load and build plotly.js](#alternative-ways-to-load-and-build-plotlyjs)
2525
* [Documentation](#documentation)
2626
* [Bugs and feature requests](#bugs-and-feature-requests)
2727
* [Contributing](#contributing)
@@ -39,17 +39,17 @@ npm i --save plotly.js-dist-min
3939
and use import or require in node.js
4040
```js
4141
// ES6 module
42-
import Plotly from 'plotly.js-dist-min';
42+
import Plotly from 'plotly.js-dist-min'
4343

4444
// CommonJS
45-
var Plotly = require('plotly.js-dist-min');
45+
var Plotly = require('plotly.js-dist-min')
4646
```
4747

4848
---
4949
## Load via script tag
5050

5151
### The script HTML element
52-
> In the examples below `Plotly` object is added to the window scope by `script` and `import`. The `newPlot` method is then used to draw an interactive figure as described by `data` and `layout` into the desired `div` here named `gd`. As demonstrated in the example above basic knowledge of `html` and [JSON](https://en.wikipedia.org/wiki/JSON) syntax is enough to get started i.e. with/without JavaScript! To learn and build more with plotly.js please visit [plotly.js documentation](https://plotly.com/javascript).
52+
> In the examples below `Plotly` object is added to the window scope by `script`. The `newPlot` method is then used to draw an interactive figure as described by `data` and `layout` into the desired `div` here named `gd`. As demonstrated in the example above basic knowledge of `html` and [JSON](https://en.wikipedia.org/wiki/JSON) syntax is enough to get started i.e. with/without JavaScript! To learn and build more with plotly.js please visit [plotly.js documentation](https://plotly.com/javascript).
5353
5454
```html
5555
<head>
@@ -67,6 +67,14 @@ var Plotly = require('plotly.js-dist-min');
6767
</body>
6868
```
6969

70+
Alternatively you may consider using [native ES6 import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) in the script tag.
71+
```html
72+
<script>
73+
import "https://cdn.plot.ly/plotly-2.0.0-rc.3.min.js"
74+
Plotly.newPlot("gd", [{ y: [1, 2, 3] }]);
75+
</script>
76+
```
77+
7078
Fastly supports Plotly.js with free CDN service. Read more at <https://www.fastly.com/open-source>.
7179

7280
### Un-minified versions are also available on CDN
@@ -90,8 +98,8 @@ There are two kinds of plotly.js bundles:
9098
2. Custom bundles you can create yourself to optimize the size of bundle depending on your needs. Please visit [CUSTOM_BUNDLE](https://github.com/plotly/plotly.js/blob/master/CUSTOM_BUNDLE.md) for more information.
9199

92100
---
93-
## Alternative ways to require or build plotly.js
94-
If your library needs to bundle or directly require [plotly.js/lib/index.js](https://github.com/plotly/plotly.js/blob/master/lib/index.js) or parts of its modules similar to [index-basic](https://github.com/plotly/plotly.js/blob/master/lib/index-basic.js) in some other way than via an official or a custom bundle, or in case you want to tweak the default build configurations of `browserify` or `webpack`, etc. then please visit [`BUILDING.md`](https://github.com/plotly/plotly.js/blob/master/BUILDING.md).
101+
## Alternative ways to load and build plotly.js
102+
If your library needs to bundle or directly load [plotly.js/lib/index.js](https://github.com/plotly/plotly.js/blob/master/lib/index.js) or parts of its modules similar to [index-basic](https://github.com/plotly/plotly.js/blob/master/lib/index-basic.js) in some other way than via an official or a custom bundle, or in case you want to tweak the default build configurations of `browserify` or `webpack`, etc. then please visit [`BUILDING.md`](https://github.com/plotly/plotly.js/blob/master/BUILDING.md).
95103

96104
---
97105
## Documentation

0 commit comments

Comments
 (0)