Skip to content

feat(outputs): detect and inject plotly.js for text/html outputs #1533

@rgbkrk

Description

@rgbkrk

Context

When Plotly uses non-default renderers (notebook, iframe_connected), it emits text/html output containing <script> tags that reference window.Plotly or require('plotly'). Currently, plotly.js is only injected into iframes when application/vnd.plotly.v1+json is detected in the output MIME types.

This means text/html Plotly outputs from these backends silently fail — the scripts execute but window.Plotly is undefined.

Possible Approach

Scan text/html output content for known Plotly signatures (e.g., Plotly.newPlot, require(['plotly'], require("plotly")) before rendering. If detected, inject plotly.js into the iframe before the HTML is rendered.

This would be similar to how getRequiredLibraries() scans MIME types today, but extended to peek at HTML content for known library references.

Notes

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