-
Notifications
You must be signed in to change notification settings - Fork 328
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
Configurably vendor all external JS/CSS #166
Conversation
I think this all sounds awesome, though I am also not qualified to vet this PR :-) Maybe @hoetmaaiers has thoughts? @bollwyvl a bit off-topic, but do you think the changes like the one in this PR could solve jupyter-book/thebe#196 ? |
First of all, the work of vendoring in more (if not all) dependencies into the project great. I also have the preference of bundling all dependencies into the project and not depend on CDN's for this. Do we even want the external CDN dependency option to be available? I prefer simplicity and one-way of doing stuff. @choldgraf of @jorisvandenbossche , has this been discussed before? The webpack approach indeed is somewhat against the core Webpack idea of bundling assets together. Still good work done @bollwyvl. This approach has the advantage of outputting individual javascript & css assets which also keep them visible in the network devtool. The Webpack preffered approach would bundle all vendor assets in a |
@bollwyvl thanks a lot! I just had a chat with @hoetmaaiers, and I think there are two main questions:
|
type="configuration", | ||
location=pagename, | ||
) | ||
warned["mathjax_path"] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bollwyvl can you explain the mathjax situation a bit more?
So sphinx has an option to set the mathjax path (https://www.sphinx-doc.org/en/master/usage/extensions/math.html#confval-mathjax_path). But if we use our vendored assets (which included mathjax), we override what a user might have configured for mathjax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, it's all rather mysterious to me as well!
The math extension adds this configurable and then at env-updated
, it adds the mathjax link. I don't know how to intercept it doing that, hence this whole rube goldberg setup.
In sphinx <3
(which i assume needs to be supported) the only way to control the order is the actual extensions
order in setup.py
, but themes are "special" and don't go there. So it checks whether mathjax_path
is set to the default cloudflare
value (which is luckily kept around), and will replace only that.
As a user, one can set it to whatever is wanted (e.g. for SVG output) in conf.py
and it would still be respected. But vendoring all of MathJax is 75mb, so i just tried to bring in everything that was related to the default output, so if one did want SVG, they'd have to bring all the assets into their _static
. This would probably need documentation.
I would prefer vendor-only, as well, was just trying to keep it backwards compatible, since I don't like surprises in my docs build chain. This also would also remove any version matching issues in the urls vs what's coming from
The workarounds I tried for bootstrap/jquery/popper vs webpack are not great, and require lots of shims, etc. I will not be working up an alternate PR with that approach 😬. MathJax will basically not go in your bundle, I don't really recommend trying. Also, see 75mb. |
While a good idea, I am not sure if it is within the scope of this PR, as it seems like something for which a jinja/sphinx solution should already exist, and may require additional configuration. |
Unfortunately, I don't really see how this would help there... |
Further, to my understanding, it would be possible for a theme user to overload an individual asset by just putting a same-named one in place. For example, this loads the entire |
I dare to say we can also be more size-conscious, since we only use a small part of Bootstrap? |
Sure. By default, using Similarly for font-awesome, you can subset just the icons you need... but again, if downstreams expect everything there, there would need to be some form of escape hatch, even if it's to load everything. |
I agree on you thoughts on including the full bootstrap and fontawesome packages for now. This PR can be closed in favour of #169 I think? |
This has bit-rotted, and I don't intend to fix it, closing! |
Hi folks! Thanks for the great theme!
I'd like to start using it all over, but #89 is real, for all kinds of reasons, for all kinds of folks.
This is an approach to rooting out the last of the CDN assets.
The big'ns are:
bootstrap
(popper.js
is already in thebundle
, or we can summon up a smaller one)popper
... is it being used anywhere?lato
open sans
mathjax
font-awesome
Here's a little "victory lap" in the browser, with my wifi turned off, and these settings on
sphinx<3
:The following caveats:
use_public_cdns
toTrue
by default, to minimize end user changesrequire.js
Thanks again!