]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #82315 - jsha:font-display-swap, r=GuillaumeGomez
authorYuki Okushi <huyuumi.dev@gmail.com>
Thu, 4 Mar 2021 11:01:04 +0000 (20:01 +0900)
committerGitHub <noreply@github.com>
Thu, 4 Mar 2021 11:01:04 +0000 (20:01 +0900)
commit569f0330d8e88aca3fabdfcb9b2dded9177002ce
treed2d94b182227ff2b5e1b5f8b1250068906bcbafa
parent36b7bef1cb0fb9d989f6c6e5ae9f001dea1b6a14
parentf9cfe1583b18052bc5f42d92e8973e18ba404b19
Rollup merge of #82315 - jsha:font-display-swap, r=GuillaumeGomez

Improve page load performance in rustdoc

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.

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. Note that users without cached fonts will see text, and then see it reflow. For `docs.rust-lang.org`, [setting caching headers will help a lot](https://github.com/rust-lang/simpleinfra/issues/62).

Generated output at https://jacob.hoffman-andrews.com/rust/flow-improvements/std/string/struct.String.html.
src/librustdoc/html/layout.rs