I have also seen “requirejs” instead of “require” so I switched to that but no difference.
Is RequireJS supported by JupyterLab? If not, how do I enable it? I’ve tried looking around under extensions, but am getting an error (shows 500 in jupyterlab’s console log whenever that panel loads.)
I installed JupyterLab via pip under Python 3.8.11-
Ordinary JavaScript code executes just, but I would prefer to programmatically use JS libraries via RequireJS, and not hand-craft script tags to include them.
requirejs is not available directly from jupyterlab, nor would your scripts generally know where they are on the page.
You work around some of these design choices by bringing display your own HTML, with a <script> tag, and a <div id="my-div>`, etc. and then doing whatever you need to do… but generally these approaches will end up being brittle over time.
Thanks for your reply. Probably I’m looking at old samples- how are folks utilising d3 -or other browser-based JS visualization packages- in Jupyter nowadays? I prefer to remain on the FOSS side of things, rather than a commercial or freemium graphical package.
The current recommended way is to develop prebuilt extensions using the jupyter labextension command line and tooling. This leverages the webpack module federation system under the hood.
Thank you both for your thoughtful replies. I was hoping for better JS support, beyond %%javascript -such as sharing top-level JS declarations between cells.
It’s cool that people are making JL extensions for graphs, and that’s a bit out of scope for me right now. And, possibly I’ve reached acceptance that what I wanted to do with JL is beyond its scope, and I need another approach. D3 is the crack of data visualization, and I must admit to being addicted, lol.
I looked into observablehq.com’s D3 notebooks, but they treat Python like JL treats JS, heh, so not much joy there unless I switch over to JS. But maybe both, JL for dev, D3/Obs for visualization delivery.
I guess that you got answers about developing extensions because the topic was in the extensions category, but if you are just looking for a way to use d3.js for yourself, Display d3.js visualisation in Jupyter Lab - Stack Overflow may help (though I do not know why they are wrapping the code in Javascript, I think that %%javascript magic would work here).