Skip to content

Commit 9e2ff2d

Browse files
committed
Reduced plot size by outsourcing plotly.min.js
1 parent b15aa1c commit 9e2ff2d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

plotly/offline/offline.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import json
99
import os
10+
import shutil
1011
import uuid
1112
import warnings
1213
from pkg_resources import resource_string
@@ -42,8 +43,9 @@ def download_plotlyjs(download_url):
4243

4344

4445
def get_plotlyjs():
45-
path = os.path.join('offline', 'plotly.min.js')
46-
plotlyjs = resource_string('plotly', path).decode('utf-8')
46+
# path = os.path.join('offline', 'plotly.min.js')
47+
# plotlyjs = resource_string('plotly', path).decode('utf-8')
48+
plotlyjs = '</script><script src="plotly.min.js">'
4749
return plotlyjs
4850

4951

@@ -315,6 +317,14 @@ def plot(figure_or_data,
315317
).format(id=plotdivid)
316318

317319
if output_type == 'file':
320+
src_path = os.path.join(
321+
os.path.dirname(__file__), 'plotly.min.js'
322+
)
323+
# src_path = resource_string('plotly', path)
324+
dest_path = os.path.join( os.path.dirname( filename ), 'plotly.min.js')
325+
if os.path.exists( dest_path ) is False:
326+
shutil.copy( src_path, dest_path )
327+
318328
with open(filename, 'w') as f:
319329
if include_plotlyjs:
320330
plotly_js_script = ''.join([

0 commit comments

Comments
 (0)