You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is executed by the kernel. However, once the output is displayed and stored in the document, it is the javascript output that is evaluated on page load.
We could think about delaying this rendering until kernels are ready, but this would be worse for most javascript and html outputs that don't talk to the kernel. A futures-based approach that probably works best in JupyterLab is an alternative.
Perhaps my workaround could be integrated into it? So when it's stored in the document it's wrapped with:
if (IPython.notebook.kernel) { <body of js magic> }
and thus it won't run on load. It's unlikely that a user will want js to run in the notebook automatically on load, no? Perhaps this assumption is wrong and then this idea is not a good one.
Second best is to document this workaround inside the js magic document?
Create nb with a cell:
Now save the notebook, close it and then re-open it. When you do that, under that cell suddenly you will see an error in red:
That means the browser has parsed some js code and it tried to run it. This is the error in chrome, it will probably different in a different browser.
Perhaps a more demonstrative example is:
and yet I get an alert pop up as soon as I open the nb in jupyter notebook.
Why do we have the js magic run by the browser?
Moreover this problem happens even if I don't use
%%javascript
, but delegate it to a function:and then have just:
it still pops the alert on nb load.
I found a workaround that prevents the whole js code from running on nb load:
It works since
IPython.notebook.kernel
is not yet defined when the nb just loads.work environment:
Server 5.7.6
Python 3.7.2
IPython 7.3.0
and then also tested with the latest with the same results.
Thanks.
The text was updated successfully, but these errors were encountered: