jupyter-book / thebe

Turn static HTML pages into live documents with Jupyter kernels.
https://thebe.readthedocs.io
BSD 3-Clause "New" or "Revised" License
395 stars 68 forks source link

Dynamically load jQuery #215

Open joelachance opened 4 years ago

joelachance commented 4 years ago

Based on the comment here: https://github.com/minrk/thebelab/pull/189#issuecomment-621195179, we want to dynamically load jQuery based on what is currently on the page.

  1. If the site has an older version, load the version we need and namespace it only for Thebelab (e.g. window.thebelab.$.
  2. If the site doesn't have any version, go ahead and load the latest. Add a namespace at window.$.
  3. Last, if the site has the version we currently need, do nothing and use the current (loaded) version. Namespace at window.$.

We'll want add some logic as well to make sure we're pointing at the right namespace, so something like: $ = window.$ ? window.$ : window.thebelab.$, or something similar (with more null checks :))

choldgraf commented 4 years ago

I think it's a good idea - we've run into some awkwardness with multiply jqueries in the pydata sphinx theme as well 👍