[IPython-dev] Sourcing a javascript file from a notebook, and writing local javascript

Andrew Gibiansky andrew.gibiansky at gmail.com
Sat May 31 12:41:23 EDT 2014

I'm not an IPython dev, but I *believe* that embedding JS into a Markdown
cell has indeed been deprecated, for security reasons. I now experiment by
putting things in custom.js.

Code in custom.js I think has all the privileges that normal Javascript
has, so you should be free to load external files and scripts. You can
include your own JS files using require.js:


In a similar way you should be able to load foreign JS files, I think; I
don't know require.js very well though. You could probably also just append
a <script> tag to the DOM with a proper src attribute :)

-- Andrew Gibiansky

On Sat, May 31, 2014 at 5:05 AM, Clare Sloggett <claresloggett at gmail.com>

> Hi all,
> I was playing around with embeddable javascript libraries and seeing if I
> could make use them from a Notebook. My first attempt was to try the
> simplest thing possible; embed it in a markdown cell. The javascript I was
> trying to embed wants to both source an external file, and then use it via
> some local javascript code, like
>    <script language="javascript" src="http://some-url/library.js
> "></script>
>    <script language="javascript">
>    ... code ...
>    </script>
> In Notebook 1.x, the local code executes but throws an error about
> undefined variables, suggesting that the external javascript file was not
> loaded. Is this expected?
> In Notebook 2.0, so far as I can tell, none of it executes at all.
> Am I right in thinking that embedding Javascript into a markdown cell has
> been deprecated? Do I need to put it into custom.js instead? And, will I be
> able to source the remote file from there, or will I need to make that
> library local as well?
> Sorry if this is a naive question, a lot of aspects of this are new to me.
> I'm just looking for the most straightforward and lightweight approach so I
> can experiment with my code.
> Thanks in advance,
> Clare
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140531/64ef3ce1/attachment.html>

More information about the IPython-dev mailing list