Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda