Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Setting Javascript Global Variables in Colab Notebook

I am looking at how to load an external JS URL in a Google Colab notebook once and have it be available in all subsequent cells.

It seems that Google Colab uses a different worker thread or other isolation for each notebook cell. This means that doing something like the solution found in Is it impossible to load a javascript library in a Google colab cell? to load external libraries in one cell works for that cell:

from IPython.display import display, Javascript
display(Javascript(url="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"))
display(Javascript('''console.log($);'''))

but move to the next cell and run:

display(Javascript('''console.log($);'''))

and console will report undefined variable: $.

I have tried setting the variable in Window and globalThis to no avail. Anyone have success?

(The library I need is not JQuery. Just using it as an example)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!