Description / Summary
I did a quick lighthouse audit on Jupyter Book, and discovered that a large chunk of our Javascript loading is coming from loading the JS bundles needed for Jupyter widgets (there are some other improvements we can make too, will open other issues for that):

This is something we could load in a more restrictive way. Here are a few ideas from anticipated easiest-to-hardest:
Load this JS bundle only if:
- The page is an
ipynb file
- The page is known to have notebook content (e.g., also covering MyST Markdown Notebooks)
- The page is known to have widget content on it (maybe as part of the CellOutputBundle parsing logic?)
Value / benefit
This could save a lot of unnecessary JS loading, and speed up page load times.
Implementation details
I think these are the two libraries we could target:
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script src="https://unpkg.com/@jupyter-widgets/html-manager@^0.20.0/dist/embed-amd.js"></script>
somewhere around here:
|
require_url_default = ( |
|
REQUIRE_URL_DEFAULT |
|
if "jupyter_sphinx_require_url" not in app.config |
|
else app.config.jupyter_sphinx_require_url |
|
) |
|
embed_url_default = ( |
|
None |
|
if "jupyter_sphinx_embed_url" not in app.config |
|
else app.config.jupyter_sphinx_embed_url |
|
) |
|
|
|
if require_url_default: |
|
builder.add_js_file(require_url_default) |
|
embed_url = embed_url_default or DEFAULT_EMBED_REQUIREJS_URL |
|
else: |
|
embed_url = embed_url_default or DEFAULT_EMBED_SCRIPT_URL |
|
if embed_url: |
|
builder.add_js_file(embed_url) |
Tasks to complete
No response
Description / Summary
I did a quick lighthouse audit on Jupyter Book, and discovered that a large chunk of our Javascript loading is coming from loading the JS bundles needed for Jupyter widgets (there are some other improvements we can make too, will open other issues for that):
This is something we could load in a more restrictive way. Here are a few ideas from anticipated easiest-to-hardest:
Load this JS bundle only if:
ipynbfileValue / benefit
This could save a lot of unnecessary JS loading, and speed up page load times.
Implementation details
I think these are the two libraries we could target:
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script><script src="https://unpkg.com/@jupyter-widgets/html-manager@^0.20.0/dist/embed-amd.js"></script>somewhere around here:
MyST-NB/myst_nb/__init__.py
Lines 284 to 301 in 2cc1260
Tasks to complete
No response