From 577177c5bdb30598f9f4a0ebb94150a3a14d798a Mon Sep 17 00:00:00 2001 From: Josh Burkart Date: Fri, 1 Jan 2016 20:06:42 -0800 Subject: [PATCH] Change to offline.init_notebook_mode() Make init_notebook_mode() only import the JS library once. Otherwise if someone puts it at the top of a Jupyter cell and it gets executed every time (typical pattern of usage?), it adds ~1 s to the cell's execution time. --- plotly/offline/offline.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index cb9e3762bed..306f0e68be3 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -46,15 +46,16 @@ def init_notebook_mode(): from IPython.display import HTML, display global __PLOTLY_OFFLINE_INITIALIZED + if not __PLOTLY_OFFLINE_INITIALIZED: + display(HTML('' + + '')) __PLOTLY_OFFLINE_INITIALIZED = True - display(HTML('' + - '')) def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',