Plots.jl: using Plots unconditionally inserts 16MB of javascript into notebooks

Created on 5 Sep 2018  路  10Comments  路  Source: JuliaPlots/Plots.jl

When Plots is loaded for the first time __init__() is run which unconditionally includes the backends/plotly.jl file. If we are in a notebook, this injects 16MB of Javascript from the following lines:

https://github.com/JuliaPlots/Plots.jl/blob/80151ac1a30c498592ac94ee03d5a7af6d2df8de/src/backends/plotly.jl#L82-L96

Seems unnecessary, especially if one does not use Plotly at all.

Most helpful comment

It is likely still true because those include don't fire on the second using either (because the package is already loaded).

All 10 comments

Given that plotly isn't the default, could we just display this HTML when calling plotly()?

Yes that seems like the best solution.

For those that hit this, a workaround is to evaluate the using Plots cell twice. The second time, the 16MB javascript will be overwritten since this injection only happen on __init__ time (which doesnt run on the second evaluation of the cell).

this injection only happen on __init__ time

That's no longer true with https://github.com/JuliaPlots/Plots.jl/pull/1772, I guess. But this issue will be my next project, so I hope a fix will be available soon.

It is likely still true because those include don't fire on the second using either (because the package is already loaded).

See also this issue https://github.com/JuliaPlots/Plots.jl/issues/1780 where @jlperla has some relevant considerations.

Yes, sorry I missed this when posting. Also, @sglyon has some trick with PlotlyJS that uses WebIO that he said could work.

That said, I am using GR, so don't really care

Does the plotly backend even work with IJulia right now? It never has for me. If not, can this whole thing be removed temporarily so it doesn't break working backends, and a quick tag put in for everyone teaching with jupyter this term?

I think master does not have this problem.

master seems to have that issue, but it is platform dependent or something - I at least don't get plotly to work for my linux + windows PC on Plots.jl master - but it works for e.g. @daschw.
The good news is, that I fixed it in https://github.com/JuliaPlots/Plots.jl/pull/1777.
If anyone can try & confirm that this branch fixes all issues, that'd be great :)

This can be closed with #1777

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PallHaraldsson picture PallHaraldsson  路  4Comments

kleinschmidt picture kleinschmidt  路  3Comments

daschw picture daschw  路  3Comments

apalugniok picture apalugniok  路  3Comments

kersulis picture kersulis  路  5Comments