jupyterlite-sphinx
jupyterlite-sphinx copied to clipboard
Delegate to website authors and users for enabling TryExamples buttons on devices where they are currently disabled
@hoodmane recently pointed out that he is unable to access the examples for the NumPy devdocs on his computer, so pages like https://numpy.org/devdocs/reference/generated/numpy.sin.html don't show the buttons.
I've opened this issue so that we could envision an improvement where we give website authors the ability to take the decision of disabling the examples, rather than taking the decision of disabling them ourselves and hardcoding that in our code. Another improvement could be to allow users to enable the examples somehow even if they are disabled.
The former should be easier, and we would need to think about the latter as the console is difficult to bring up for mobile devices.
After a little further discussion, @hoodmane questions why we need to hide the buttons at all, as we could instead make users aware of the consequences – by adding a simple prompt like
alert("We think you might be on data. This is a big download. Proceed?")
before JupyterLite is loaded, potentially similar to how we don't load JupyterLite instantly for the Replite directive but hide it behind the big button. That is, there are more choices to be explored (site authors only):
- some would like the examples buttons completely disabled (like it is now)
- some would like them to be enabled, but with a warning for high bandwidth usage before JuptyerLite loads and the kernels are instantiated
- some may not want this prompt at all even on mobile devices
We could add a jupyterlite_try_examples_on_mobile_devices configuration option with three choices: "disabled", "warn", or "enabled", and it could be set to "disabled" for keeping backwards compatibility. We could think of a better and shorter name, though.
P.S. We could have also used the NetworkInformation API to distinguish between mobile data and WiFi users, but it's not baseline yet: https://caniuse.com/netinfo.
The above comment still only applies to site authors, and not site users – we still need to think about how users can enable the examples even if the site authors are more conservative in their approach and don't want to.