[IPython-dev] loading a static JS file when loading an IPython extension in the notebook

Thomas Kluyver takowl at gmail.com
Fri Jul 11 10:50:28 EDT 2014

On 10 July 2014 07:48, Cyrille Rossant <cyrille.rossant at gmail.com> wrote:

> What is the best way to write an IPython extension such that
> `%load_ext myext` loads `myscript.js` in the current notebook? If
> possible, I'd prefer to avoid asking users to make manual changes to
> custom.js or similar.

We are going to come up with a mechanism for installing and using notebook
extensions that doesn't depend on IPython kernel-side extensions, because
it should be independent of the kernel language. So for pure JS extensions,
I'd rather get that sorted out than have hacks to load them from Python.

However, there is a need for code which has both a Python component and a
JS piece. In that case, you can load the JS by doing something like this:

pkgdir = os.path.dirname(__file__)
nbextensions.install_nbextension([os.path.join(pkgdir, 'myjsdir')], symlink=

This is what I do in mobilechelonian:

We are also going to build a mechanism to allow widgets to specify the file
where their JS part is contained, which will be loaded with requirejs,
which will make this unnecessary in many cases.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140711/c8a8f559/attachment.html>

More information about the IPython-dev mailing list