ipywidgets
                                
                                 ipywidgets copied to clipboard
                                
                                    ipywidgets copied to clipboard
                            
                            
                            
                        Support loading widgets from a CDN in JupyterLab
Problem
I am working on creating a custom widget and making it usable on all major notebook frontends.
Currently, if you publish an NPM package, than this supports VS Code, Colab, and Jupyter Book, because all of those frontends will look up the extension on a CDN (unpkg or jsdelivr) and download it remotely.
However, to get the extension to run in JupyterLab, you have to create a custom jupyterlab extension and distribute it via Python. This complicates the build process and makes it more cumbersome to have a write-once-run-anywhere widget.
Proposed Solution
If the jupyterlab widgets manager supported CDNs, then it would be a slightly less complicated experience to publish a custom widget package.
Other Details
A few relevant points:
- The bundles published on CDN are AMD modules, so the jlab manager would need to somehow be able to load AMD modules (e.g., include requirejs code)
- If the jlab manager grew this capability, I think it would be important to have it toggled with a setting. Not sure if that setting should default to on or off.
- The code to support something like this is in the HTML manager package: https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/html-manager/src/libembed-amd.ts
- Voila also supports widgets via loading them from CDN, but I think they are actually moving to using the jlab widget packages.
As an aside: There might be a benefit to solving this on the JupyterLab level. Having JupyterLab be able to load/install extensions from CDN/NPM would also bring benefits to lab.