diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index ed7a48d1..ce2b704c 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -907,7 +907,19 @@ function plotly_html_body(plt, style = nothing) requirejs_prefix = "" requirejs_suffix = "" if isijulia() - requirejs_prefix = "require(['Plotly'], function (Plotly) {" + # require.js adds .js automatically + plotly_no_ext = + use_local_dependencies[] ? ("file:///" * plotly_local_file_path[]) : "https://cdn.plot.ly/$(_plotly_min_js_filename)" + plotly_no_ext = plotly_no_ext[1:end-3] + + requirejs_prefix = """ + requirejs.config({ + paths: { + Plotly: '$(plotly_no_ext)' + } + }); + require(['Plotly'], function (Plotly) { + """ requirejs_suffix = "});" end diff --git a/src/init.jl b/src/init.jl index d340fda7..22bb4b51 100644 --- a/src/init.jl +++ b/src/init.jl @@ -89,23 +89,6 @@ function __init__() use_local_dependencies[] = use_local_plotlyjs[] - if isijulia() - # require.js adds .js automatically - plotly_no_ext = - use_local_dependencies[] ? ("file:///" * plotly_local_file_path[]) : "https://cdn.plot.ly/$(_plotly_min_js_filename)" - plotly_no_ext = plotly_no_ext[1:end-3] - - display("text/html", """ - - """) - end - @require FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" begin _show(io::IO, mime::MIME"image/png", plt::Plot{<:PDFBackends}) = _show_pdfbackends(io, mime, plt)