from IPython.display import HTML, Javascript, display
This notebook shows how the display of JavaScript is semi-broken on nbviewer.
First, this cell shows that JavaScript output is not displayed:
display(Javascript("alert('hi')"))
display(HTML("<h3>Hi there</h3>"))
This cell shows that when JavaScript code in a script
tag is run, jQuery is not defined. The reason for this is that jQuery is loaded at the bottom of the page and the cell's HTML is loaded when the document body is loaded.
HTML("""
<script>
if (typeof $ === 'undefined') {
alert('jQuery is not defined');
} else {
alert('jQuery is defined');
}
</script>
""")
This cell shows that require.js
is not being loaded:
HTML("""
<script>
if (typeof require === 'undefined') {
alert('require.js is not defined');
} else {
alert('require.js is defined');
}
</script>
""")