On an IPython laptop, you can expect the following code to force Raphael.js to successfully boot into the global namespace.
from IPython.display import Javascript raphael_url = "https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js" Javascript('alert(Raphael);', lib=[raphael_url])
However, it does not work in recent versions of IPython that use require.js. Turns out Raphael.js, which loads IPython using jQuery.getScript() , recognizes the presence of require.js and does not by itself insert itself into the global namespace. In fact, if javascript code is first executed that removes the window.define object, Raphael no longer implements require.js, and it inserts itself into the global namespace as I would like. In other words, the above code works after doing the following:
Javascript('window.define = undefined;')
Thus, the only way I can get Raphael to boot in the latest IPython laptop is to remove (or delay) window.define .
Having identified the problem, I am not sufficiently aware that require.js knows which piece of software acts against the protocol. Does Raphael use a poor require.js test for existence? Should IPython use require.js directly instead of jQuery.getScript() when it loads the user-provided javascript libraries? Or is there a way I have to use the require.js user who will give me a Raphael object without any special hacks? (If the answer to the last question is yes, is there a way I can also support older versions of IPython laptops that don't use require.js?)
source share