Skip to content

Avoiding jsDelivr CDN and using local or other #525

Closed

Description

How can I use a different CDN or local file for plotly-x.y.z.min.js?

Activity

  1. jd-foster commented on May 7, 2026

    @jd-foster
    Collaborator

    The way to do this is through the Base.show methods implemented in PlotlyBase here:
    https://github.com/sglyon/PlotlyBase.jl/blob/master/src/output.jl

    How are you displaying your plots (in the browser, via the REPL, saving with Kaleido)?

  2. createyourpersonalaccount commented on May 7, 2026

    @createyourpersonalaccount
    Author

    Great, thank you. It's the include_plotlyjs option of the to_html function. Now I just need to figure out how to wire things together for my two use-cases:

    1. View notebook in browser locally
    2. Publish static blog

    I'm mostly interested in 1. for now! Any tips appreciated.

  3. jd-foster commented on May 8, 2026

    @jd-foster
    Collaborator

    PlotlyJS exports the savefig function, and you can pass the include_plotlyjs keyword to argument directly.
    So

    julia> using PlotlyJS
    
    julia> p1 = plot(scatter(;y=randn(3)));
    
    julia> PlotlyBase.embed_plotlyjs = false  # this puts the path in the file (and actually covers up a bug!)
    
    julia> open("my_local_plot.html", "w") do io
               PlotlyBase.to_html(io, p1.plot; include_plotlyjs="assets/plotly-2.33.0.min.js", include_mathjax=missing)
           end
  4. createyourpersonalaccount commented on May 8, 2026

    @createyourpersonalaccount
    Author

    Thank you! Now I just have to figure out how to do this in Pluto.jl's interactive notebook, but that might be a question for them.

    PS. It's a bit confusing that the readme says "This package constructs plotly graphics using all local resources." isn't it? By default that's not true for plotly.min.js...

  5. jd-foster commented on May 8, 2026

    @jd-foster
    Collaborator

    Fair point - the language should be updated to be clearer.

    I assume you know about this?
    https://github.com/JuliaPluto/PlutoPlotly.jl

  6. createyourpersonalaccount commented on May 9, 2026

    @createyourpersonalaccount
    Author

    Yes I use it! I should've said that I want the js script to be local for PlutoPlotly.jl. I believe they've hardcoded the value. On the other hand, I'm seriously considering paying that license to Mathematica because dynamic plots need a lot of fine-tuning with plotly :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions