Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update comments describing the type of include_plotlyjs
  • Loading branch information
marthacryan committed Sep 11, 2024
commit e2cfbf6cc0a9d30206cf5512831e9138147793c9
18 changes: 0 additions & 18 deletions packages/python/plotly/plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3528,12 +3528,6 @@ def to_html(self, *args, **kwargs):
plotly.min.js bundle that is assumed to reside in the same
directory as the HTML file.

If 'require', Plotly.js is loaded using require.js. This option
assumes that require.js is globally available and that it has been
globally configured to know how to find Plotly.js as 'plotly'.
This option is not advised when full_html=True as it will result
in a non-functional html file.

If a string that ends in '.js', a script tag is included that
references the specified path. This approach can be used to point
the resulting HTML file to an alternative CDN or local bundle.
Expand Down Expand Up @@ -3618,12 +3612,6 @@ def write_html(self, *args, **kwargs):
is included in the output. HTML files generated with this option are
fully self-contained and can be used offline.

If 'cdn', a script tag that references the plotly.js CDN is included
in the output. HTML files generated with this option are about 3MB
smaller than those generated with include_plotlyjs=True, but they
require an active internet connection in order to load the plotly.js
library.

If 'directory', a script tag is included that references an external
plotly.min.js bundle that is assumed to reside in the same
directory as the HTML file. If `file` is a string to a local file
Expand All @@ -3637,12 +3625,6 @@ def write_html(self, *args, **kwargs):
directory because the plotly.js source code will be included only
once per output directory, rather than once per output file.

If 'require', Plotly.js is loaded using require.js. This option
assumes that require.js is globally available and that it has been
globally configured to know how to find Plotly.js as 'plotly'.
This option is not advised when full_html=True as it will result
in a non-functional html file.

If a string that ends in '.js', a script tag is included that
references the specified path. This approach can be used to point
the resulting HTML file to an alternative CDN or local bundle.
Expand Down
24 changes: 0 additions & 24 deletions packages/python/plotly/plotly/io/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,10 @@ def to_html(
is included in the output. HTML files generated with this option are
fully self-contained and can be used offline.

If 'cdn', a script tag that references the plotly.js CDN is included
in the output. The url used is versioned to match the bundled plotly.js.
HTML files generated with this option are about 3MB smaller than those
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep cdn option as it could help reduce smaller HTML files.
But for loading that we shouldn't use requirejs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok - but we don't have a cdn currently right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we publish every version to CDN.
It's only the -latest version is no longer updated (plotly/plotly.js#5697) since plotly.js v2 and stayed as latest v1 version i.e. 1.58.5.
So we should be able to continue loading from CDN by specifying the exact version.
To achieve that you could add a separate script tag instead of requirejs to load e.g.

<script src="https://cdn.plot.ly/plotly-2.35.1.min.js" charset="utf-8"></script>

Or alternatively for async loading

<script type="module">
    import "https://cdn.plot.ly/plotly-2.35.2.min.js"
    Plotly.newPlot("gd", [{ y: [1, 2, 3] }])
</script>

generated with include_plotlyjs=True, but they require an active
internet connection in order to load the plotly.js library.

If 'directory', a script tag is included that references an external
plotly.min.js bundle that is assumed to reside in the same
directory as the HTML file.

If 'require', Plotly.js is loaded using require.js. This option
assumes that require.js is globally available and that it has been
globally configured to know how to find Plotly.js as 'plotly'.
This option is not advised when full_html=True as it will result
in a non-functional html file.

If a string that ends in '.js', a script tag is included that
references the specified path. This approach can be used to point
the resulting HTML file to an alternative CDN or local bundle.
Expand Down Expand Up @@ -392,12 +380,6 @@ def write_html(
is included in the output. HTML files generated with this option are
fully self-contained and can be used offline.

If 'cdn', a script tag that references the plotly.js CDN is included
in the output. The url used is versioned to match the bundled plotly.js.
HTML files generated with this option are about 3MB smaller than those
generated with include_plotlyjs=True, but they require an active
internet connection in order to load the plotly.js library.

If 'directory', a script tag is included that references an external
plotly.min.js bundle that is assumed to reside in the same
directory as the HTML file. If `file` is a string to a local file
Expand All @@ -411,12 +393,6 @@ def write_html(
directory because the plotly.js source code will be included only
once per output directory, rather than once per output file.

If 'require', Plotly.js is loaded using require.js. This option
assumes that require.js is globally available and that it has been
globally configured to know how to find Plotly.js as 'plotly'.
This option is not advised when full_html=True as it will result
in a non-functional html file.

If a string that ends in '.js', a script tag is included that
references the specified path. This approach can be used to point
the resulting HTML file to an alternative CDN or local bundle.
Expand Down