Skip to content
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

rustdoc: CSS for all three themes is fetched #82614

Closed
jsha opened this issue Feb 28, 2021 · 0 comments · Fixed by #106915
Closed

rustdoc: CSS for all three themes is fetched #82614

jsha opened this issue Feb 28, 2021 · 0 comments · Fixed by #106915
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jsha
Copy link
Contributor

jsha commented Feb 28, 2021

Right now, light1.52.0.css, dark1.52.0.css, and ayu1.52.0.css are all loaded on each page load. These are early in the page, and as high-priority resources, they loaded first. Even with HTTP/2, they block other resources from starting their downloads (because there appears to be a limit on parallel HTTP/2 fetches made by browsers; though I need to check this).

image

These stylesheets are loaded like:

<link rel="stylesheet" type="text/css" href="../../light1.52.0.css"  id="themeStyle">
<link rel="stylesheet" type="text/css" href="../../dark1.52.0.css" disabled >
<link rel="stylesheet" type="text/css" href="../../ayu1.52.0.css" disabled >

Interestingly, the theme picker JS doesn't change the disabled property, but changes the href on the main theme:

var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
.

I think it would be more efficient to omit the second two <link>s, and instead list all the theme URLs using a data property on rustdoc-vars.

@JohnTitor JohnTitor added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 28, 2021
@camelid camelid added A-rustdoc-ui Area: rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Mar 3, 2021
@bors bors closed this as completed in 83791f9 Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
4 participants