Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Make JS async where possible #75

Merged
merged 1 commit into from
Apr 16, 2020

Conversation

davidfischer
Copy link
Contributor

This will make analytics and footer JS load asynchronously. It is possible we see slightly reduced analytics from this but I doubt it will be significant. readthedocs-doc-embed.js already waits for document.ready before doing anything so I don't think there will be a significant effect there.

Because this is only available in the newer Sphinx API app.add_js_file, it will only apply if built with Sphinx 1.8+.

Resources

@davidfischer davidfischer requested a review from a team July 22, 2019 17:37
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.

I tested this on a Bokeh build (https://bokeh-bokeh.readthedocs-hosted.com/en/readthedocs-async-js/) and I didn't find any problem. Although, the load speed was almost not increased. So, I'm not sure if we are going a bit faster with this or not.

Bokeh load time issue is another thing, though. Out of the scope of this PR.

I assume that _static/readthedocs-data.js is not possible to load in an async way, right?

@davidfischer
Copy link
Contributor Author

I assume that _static/readthedocs-data.js is not possible to load in an async way, right?

Not currently. Ideally, I think this should be inlined rather than a separate file:

<script type="application/json" id="READTHEDOCS_DATA">{...}</script>

Anywhere that needs the data could just run JSON.parse(document.getElementById('READTHEDOCS_DATA'))

That's a bigger change though and would require a number of places to change. They'd also have to try the new way and fall back to the old way...

@ericholscher ericholscher merged commit dc41709 into master Apr 16, 2020
@stsewd stsewd deleted the davidfischer/async-js-improvements branch April 16, 2020 20:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants