Skip to content

ENH: Lazy load thebe javascript#41

Merged
choldgraf merged 6 commits into
executablebooks:masterfrom
choldgraf:ENH-lazy-load
Jan 17, 2022
Merged

ENH: Lazy load thebe javascript#41
choldgraf merged 6 commits into
executablebooks:masterfrom
choldgraf:ENH-lazy-load

Conversation

@choldgraf
Copy link
Copy Markdown
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