# Javascript Error: Can't find variable: $

**URL:** <https://discourse.jupyter.org/t/javascript-error-cant-find-variable/10960>\
**Category:** Binder\
**Created:** [September 24, 2021, 11:15pm UTC](https://discourse.jupyter.org/t/javascript-error-cant-find-variable/10960 "2021-09-24T23:15:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdko](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mdko/32/5314_2.png) [@mdko](https://discourse.jupyter.org/u/mdko)\
**Post date:** [September 24, 2021, 11:15pm UTC](https://discourse.jupyter.org/t/javascript-error-cant-find-variable/10960/1 "2021-09-24T23:15:10Z")

</div>

I’m currently having an issue when trying to render in Jupyter notebooks running on BinderHub. In particular, it’s having difficulty rendering Javascript that uses `$`/acceses jQuery.

Here’s an [example](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-demo/0b99d22459b65b9de1593a8ba2e4f34df9f76c9f?urlpath=lab%2Ftree%2Fdemo%2FUntitled.ipynb):

```auto
from IPython.core.display import display, HTML, Javascript

javascript = """
$.when(
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/wavedrom/1.6.2/skins/default.js"),
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/wavedrom/1.6.2/wavedrom.min.js"),
$.Deferred(function( deferred ){
    $( deferred.resolve );
})).done(function(){
    WaveDrom.ProcessAll();
});
"""

html = """
<script type="WaveDrom">
{
  signal : [
    { name: "counter", wave: "===============", data: ["0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", "0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6"] },
  ],
  config: { hscale: 1 }
}
</script>
"""

display(HTML(html))
display(Javascript(javascript))

```

When I run it on [mybinder.org](http://mybinder.org), I get the following error:  
`Javascript Error: Can't find variable: $`

However, when I run a Jupyter notebook via a **Conda** environment, it renders correctly:

 ![Screen Shot 2021-09-24 at 4.05.14 PM](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/f/fedc34c7a6309a2b2614fc2cf96972e570fde879.png)

This was working last I checked (which was several months ago). Was access to jQuery recently changed? I haven’t been able to see any obvious change in Github or anyone else mentioning this issue. I’m not sure if this a Jupyter issue or a BinderHub issue.

One more note:  
If I instead just try to render HTML by putting those Javascript commands into `<script>` tags, it does render well:

```auto
from IPython.core.display import display, HTML, Javascript

htmlstring = """
<script src="https://cdnjs.cloudflare.com/ajax/libs/wavedrom/2.6.8/skins/default.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/wavedrom/2.6.8/wavedrom.min.js"></script>
<script type="WaveDrom">
{
  signal : [
    { name: "counter", wave: "===============", data: ["0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", "0x0", "0x1", "0x2", "0x3", "0x4", "0x5", "0x6"] },
  ],
  config: { hscale: 1 }
}
</script>
<script>WaveDrom.ProcessAll();</script>
"""

display(HTML(htmlstring))

```

Thank you

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [September 25, 2021, 5:13pm UTC](https://discourse.jupyter.org/t/javascript-error-cant-find-variable/10960/2 "2021-09-25T17:13:04Z")

</div>

Not sure what you mean by Jupyter notebook via Conda environment? Your screenshot doesn’t let us know if it is Jupyter classic notebook or JupyterLab?

Seems to work at in sessions launched from where you linked to without the javascript error in the classic interface, but I note you have to run the cell twice:

 ![binder_runs](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/e/ef5c242cc07bd0ab915896a757fa2ef6f50f5a2f.png)

See [this post and thread](https://discourse.jupyter.org/t/classic-notebook-instead-of-jupyterlab-on-mybinder-org/10714/2) if you are unaware how to control what interface gets launched and for mentions of how to switch between them. Apparently, at present clicking the Jupyter icon in the upper left goes back to JupyterLab, so you can go both directions without touching the URL or address bar. I don’t think that is expected behavior by users of the classic interface but for right now that is what happens. That logo used to go to the Jupyter Dashboard, and is what I’d prefer it eventually be changed back to.

---

<div class="post-metadata">

**Author:** ![mdko](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mdko/32/5314_2.png) [@mdko](https://discourse.jupyter.org/u/mdko)\
**Post date:** [September 25, 2021, 10:08pm UTC](https://discourse.jupyter.org/t/javascript-error-cant-find-variable/10960/3 "2021-09-25T22:08:01Z")

</div>

Thanks for the response.

> Not sure what you mean by Jupyter notebook via Conda environment? Your screenshot doesn’t let us know if it is Jupyter classic notebook or JupyterLab?

Sorry, what I should have said was that I see it working when I launch the Anaconda-Navigator on my machine, then select “Jupyter Notebook”. I wasn’t aware there was a difference between that and Jupyter Lab, and I just saw that when I try running it locally in “JupyterLab”, it also fails with the Javascript error. So it appears that the issue is with “JupyterLab”, i.e. the classic Jupyter notebook works fine when I use it either on mybinder or locally launched from the Anaconda Navigator.

> Seems to work at in sessions launched from where you linked to without the javascript error in the classic interface, but I note you have to run the cell twice:

Okay, thank you. When I run it via a classic notebook on mybinder, it works like you describe. I also note that I can click on the Jupyter icon in the upper left to get to the JupyterLab version like you say, and by going to “Help \> Launch Classic Notebook” (or changing the url) I can go to the classic version.

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [September 25, 2021, 10:43pm UTC](https://discourse.jupyter.org/t/javascript-error-cant-find-variable/10960/4 "2021-09-25T22:43:24Z")

</div>

> [@mdko](#):
>
> like you say, and by going to “Help \> Launch Classic Notebook” (or changing the url) I can go to the classic version.

You can also launch a session straight into the `tree` directory page or open a notebook in the classic mode. In case that wasn’t clear. There were examples of that on that thread I pointed at.
