From d99060f26328ec179f96b4d4dc98c0450089359c Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Sun, 30 May 2021 21:37:52 -0400 Subject: [PATCH] remove 'latest' CDN URLs --- CHANGELOG.md | 13 ++++++------- packages/python/plotly/plotly/io/_html.py | 19 ++----------------- .../plotly/plotly/tests/test_io/test_html.py | 14 +------------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d36c200f695..536d8d838d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/packages/python/plotly/plotly/io/_html.py b/packages/python/plotly/plotly/io/_html.py index b279d91fccc..ac7a642b755 100644 --- a/packages/python/plotly/plotly/io/_html.py +++ b/packages/python/plotly/plotly/io/_html.py @@ -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. @@ -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} \ """.format( - win_config=_window_plotly_config, cdn_url=cdn_url + win_config=_window_plotly_config, cdn_url=plotly_cdn_url() ) elif include_plotlyjs == "directory": @@ -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 diff --git a/packages/python/plotly/plotly/tests/test_io/test_html.py b/packages/python/plotly/plotly/tests/test_io/test_html.py index 026677c0d58..e2b2b976a7e 100644 --- a/packages/python/plotly/plotly/tests/test_io/test_html.py +++ b/packages/python/plotly/plotly/tests/test_io/test_html.py @@ -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")