Skip to content

remove 'latest' CDN URLs #3211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 6 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).


## [4.14.3] - 2021-01-12
## UNRELEASED

### Fixed
- Plotly.js cdn url will now be versioned by default for:
`include_plotlyjs='cdn'` a new `include_plotlyjs='cdn-latest'` option
has the original behaviour. Prevents likelihood of htmls generated with older
`plotly.js` versions breaking with version bumps.
[2961](https://github.com/plotly/plotly.py/pull/2961)
### Changed

- Plotly.js CDN url will now be versioned by default for HTML exports using `include_plotlyjs='cdn'` and for "connected" renderers.

## [4.14.3] - 2021-01-12

- `px.timeline()` now allows `hover_data` formatting of start and end times [3018](https://github.com/plotly/plotly.py/pull/3018)
- Small change to packaging of `plotlywidget` extension for JupyterLab 3 [3021](https://github.com/plotly/plotly.py/pull/3021)
Expand Down
19 changes: 2 additions & 17 deletions packages/python/plotly/plotly/io/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ def to_html(
generated with include_plotlyjs=True, but they require an active
internet connection in order to load the plotly.js library.

If 'cdn-latest', a script tag that always references the latest 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.
Expand Down Expand Up @@ -272,15 +266,12 @@ def to_html(
require_start = 'require(["plotly"], function(Plotly) {'
require_end = "});"

elif include_plotlyjs == "cdn" or include_plotlyjs == "cdn-latest":
cdn_url = plotly_cdn_url()
if include_plotlyjs == "cdn-latest":
cdn_url = plotly_cdn_url(cdn_ver="latest")
elif include_plotlyjs == "cdn":
load_plotlyjs = """\
{win_config}
<script src="{cdn_url}"></script>\
""".format(
win_config=_window_plotly_config, cdn_url=cdn_url
win_config=_window_plotly_config, cdn_url=plotly_cdn_url()
)

elif include_plotlyjs == "directory":
Expand Down Expand Up @@ -431,12 +422,6 @@ def write_html(
generated with include_plotlyjs=True, but they require an active
internet connection in order to load the plotly.js library.

If 'cdn-latest', a script tag that always references the latest 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 Down
14 changes: 1 addition & 13 deletions packages/python/plotly/plotly/tests/test_io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,7 @@ def fig1(request):

# HTML
# ----
def assert_latest_cdn_connected(html):
assert plotly_cdn_url(cdn_ver="latest") in html


def assert_locked_version_cdn_connected(html):
assert plotly_cdn_url() in html


def test_latest_cdn_included(fig1):
html_str = pio.to_html(fig1, include_plotlyjs="cdn-latest")
assert_latest_cdn_connected(html_str)


def test_versioned_cdn_included(fig1):
html_str = pio.to_html(fig1, include_plotlyjs="cdn")
assert_locked_version_cdn_connected(html_str)
assert plotly_cdn_url() in pio.to_html(fig1, include_plotlyjs="cdn")