-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Embed JS: fix incompatibilities with sphinx 6.x (jquery removal) #9359
Conversation
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.
I think this code is fine. However, if I understand correctly, it seems there are some edge cases we won't be handling that I suppose will break in production due to the order of the scripts loaded.
// Inject JQuery if isn't present already. | ||
if (!window.jQuery) { |
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.
What's up if this line is executed first and then jQuery is loaded by a different extension/theme/etc?
I'm thinking about this scenario;
- this code is run and we inject jQuery
- another .js file is loaded that includes jQuery
- once
domReady
is called, we will have 2 different jQuery versions/files loaded
Shouldn't we inject jQuery synchronously inside domReady
so we wait for all the scripts to be loaded first and avoid this scenario?
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.
This is going to be a problem anywhere we try to inject jquery, since the code to be executed after jquery is done loading is inside an asynchronous callback (onload). I think the only difference would be that the page won't be blocked till jquery is done downloading.
Co-authored-by: Manuel Kaufmann <[email protected]>
Is it really necessary to inject jQuery at this point? Sphinx still has jQuery, it is only planned be removed in Sphinx 6.0: sphinx-doc/sphinx#10070 Note that https://www.sphinx-doc.org/ uses the |
There are some themes on mkdocs that don't include jQuery (material). |
I have updated this PR to not inject jquery yet, so isn't blocked on that, this still removes some dependency on jquery. |
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.
This is a good refactor, it makes a lot of sense to chip away at jQuery removal like this
encodeURIComponent
, use that instead.https://github.com/sphinx-doc/sphinx/blob/b26bf0320cf3ec8a3400a70b2dc481d511ff2563/doc/_themes/sphinx13/static/_sphinx_javascript_frameworks_compat.js#L33-L33
Our theme still doesn't work becuase of readthedocs/sphinx_rtd_theme#1299.
But this PR doesn't depend on the theme, it can be merged as is.
ref sphinx-doc/sphinx#10574