htmlmanager does not seem to work with 3rd party widgets
See original GitHub issueThe output for this html is fine:
import ipywidgets as widgets
import ipywidgets.embed
slider = widgets.FloatSlider()
slider
widgets.embed.embed_minimal_html('slider.html', slider)
However, using other libraries such as ipyvolume or pythreejs does not seem to work.
from pythreejs import *
import numpy as np
from IPython.display import display
from ipywidgets import HTML, Text
from traitlets import link, dlink
ball = Mesh(geometry=SphereGeometry(radius=1),
material=LambertMaterial(color='red'),
position=[2, 1, 0])
scene = Scene(children=[ball, AmbientLight(color='#777777')])
c = PerspectiveCamera(position=[0, 5, 5], up=[0, 0, 1],
children=[DirectionalLight(color='white',
position=[3, 5, 1],
intensity=0.5)])
renderer = Renderer(camera=c,
scene=scene,
controls=[OrbitControls(controlling=c)])
display(renderer)
Chrome’s screenshot for network gives this:

When I put jupyter-threejs.js in the same folder, it gives this:

I tried to debug it, but I’m not sure what’s going on here. Not that in the last case, it even tried to fetch file:///Users/maartenbreddels/src/ipywidgets/@jupyter-widgets/base.js
(pythreejs master and ipywidgets master)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Jquery Widget CSS conflicts with third-party site - Stack Overflow
I have created one Jquery widgets which is used in many third party website. My Widgets has it's own css for widgets elements....
Read more >iPhone SE 2020 widgets doesn't support 3rd party apps
Does iPhone SE 2020 widgets support 3rd party apps? I can't seem to do it. I only see widgets from the original list....
Read more >@vscode/jupyter-ipywidgets - NPM Package Overview - Socket
umd is does not work as we have multiple entry points in webpack . Heres' the solution define('@jupyter-widgets/controls', () => widgets);.
Read more >Migrating custom widget libraries — Jupyter Widgets 8.0.2 ...
These are migration guides specifically for developers of third-party widgets. Migrating from 7.x to 8.0 . In this section, we discuss migrating...
Read more >Best Practices on Embedding Third-Party Web Widgets
Therefore, let's look at several best practices to reduce their overall impact. 1. Lazy-Loading. We can use Lazy loading to load embedded ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The root issue seems to be fixed in #1556 - now the three packages
@jupyter-widgets/base,@jupyter-widgets/controls, and@jupyter-widgets/html-managerare all defined in require on a page that just includes the embed.js script.Good catch. I don’t think that threejs has been migrated to ipywidgets 7.0.0. As far as I can tell, the migration would involve:
_model_module_versiontraitlet explicitly – at the moment it defaults to the version on the base widget (hence why it tries to look for jupyter-threejs@0.3.0 on unpkg).jupyter-js-widgetsto@jupyter-widgets/base.We should probably write a migration guide for widget libraries and make an effort to help widget library developers with the migration?
That said, looking at ipyleaflet 0.4.0-alpha1, which has been migrated, the htmlmanager still doesn’t work. As far as I can tell, this is because we’ve split the htmlmanager from the base package. Before, we could just rely on declaring that
jupyter-js-widgetsis available as an external dependency when building external widgets. Now (looking at webpack.config.js for ipyleaflet and the cookiecutter), we declare that@jupyter-widgets/baseshould be provided as an external dependency, but we don’t provide it explicitly.I can see two possible fixes:
remove the
externalsfield for the embeddable bundle for ipyleaflet (see this PR on ipyleaflet). The base widget classes then get bundled with ipyleaflet. This definitely works, but might be confusing to the user: there are then two versions of@jupyter-widgets/basein the DOM: the one provided by the html-manager and the one provided by ipyleaflet.explicitly pass in the base widgets to the requirejs configuration (presumably in
/packages/html-manager/src/embed-webpack.ts?). This could also be confusing for the end-user because they developed against one version of @jupyter-widgets/base, but when their code is embedded, they actually get a different one.