Skip to content

rustdoc: CSS for all three themes is fetched #82614

Closed
@jsha

Description

@jsha

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions