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

Improve page load performance in rustdoc #82315

Merged
merged 2 commits into from
Mar 4, 2021
Merged

Commits on Mar 3, 2021

  1. Improve page load performance in rustdoc.

    Add font-display: swap. Per https://web.dev/font-display/, this prevents
    "flash of invisible text" during load by using a system font until the
    custom font is available. I've noticed this flash of invisible text
    occasionally when reading Rust docs.
    
    Add an explicit height to icons (which already had an explicit width)
    to allow browsers to lay out the page more accurately before the icons
    have been loaded. https://web.dev/optimize-cls/.
    
    Add min-width: 115px to the crate search dropdown. When the HTML first
    loads, this dropdown includes only the text "All crates." Later, JS
    loads the items underneath it, some of which are wider. That causes
    the dropdown to get wider, causing a distracting reflow. This sets a
    min-width based on the size that the dropdown eventually becomes based
    on the crates on doc.rust-lang.org, reducing page movement during load.
    jsha committed Mar 3, 2021
    Configuration menu
    Copy the full SHA
    d3e7ffa View commit details
    Browse the repository at this point in the history
  2. Use Arial as fallback font instead of sans-serif.

    On most platforms and browsers, `sans-serif` is equivalent to Arial.
    However, on Firefox on Ubuntu (and possibly other Linuxes), `sans-serif`
    is DejaVu Sans, a much wider font. This creates a larger shift in text
    when the custom fonts finally load. Arial is a web-safe font, and
    specifying it explicitly gives us more cross-platform consistency, as
    well as reducing the layout shift that happens when fonts load.
    jsha committed Mar 3, 2021
    Configuration menu
    Copy the full SHA
    f9cfe15 View commit details
    Browse the repository at this point in the history