I'm newer in "ipython notebook" and I would to create a custom widget with ipywidgets using html and javascript. I'm using a javascript library and I wanna know if there is a way to import it inside ipython notebook.
thank u in advance
The way to import javascript files for use in a custom widget is to use require.config to load the script into the widget. For example, if you wanted to load fabric.js from https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.7.0/fabric.min.js, you would do the following (note that you don't include the ".js" in the path!)
%%javascript
require.undef('hello');
require.config({
//Define 3rd party plugins dependencies
paths: {
fabric: "https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.7.0/fabric.min"
}
});
define('hello', ["@jupyter-widgets/base", 'fabric'], function(widgets) {...
You might want to look into custom.js file it can be found in the Users\username\.ipython\profile_default\static\custom (or jupyter depending on installed versions). Here you can add links to your js files and they will run each time you open the notebooks.
Also you can have a look into notebook extensions (like these for example )