Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Lazy load thebe javascript #41

Merged
merged 6 commits into from
Jan 17, 2022

Conversation

choldgraf
Copy link
Member

@choldgraf choldgraf commented Jan 3, 2022

Description

This lazily loads the Thebe javascript bundle when the initThebe function is triggered (usually, when somebody clicks the "launch Thebe" button).

It does this by appending a script to the page header via javascript, rather than adding it to the Sphinx HTML bundle when it is created.

Rationale

In most cases, people won't need Thebe loaded on a page because they'll only have one or two pages of their docs site that have Thebe-relevant content. Rather than loading Thebe each time, this will ensure it's loaded only when actively needed. It will take a bit longer to load when people click the button, but in most cases the size of the inputs/outputs loading will likely quickly be larger than the original thebe javascript payload, so this shouldn't hurt the UX much.

Behavior changes

There's one default change with this PR: thebe will now be loaded lazily by default, whereas before it was loaded automatically on all pages by default.

closes #34
closes jupyter-book/jupyter-book#1014
closes #32

@choldgraf choldgraf marked this pull request as draft January 3, 2022 02:27
@choldgraf choldgraf marked this pull request as ready for review January 17, 2022 22:10
@choldgraf choldgraf merged commit cee16c6 into executablebooks:master Jan 17, 2022
@choldgraf choldgraf deleted the ENH-lazy-load branch January 17, 2022 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant