rustdoc: "Show declaration" causes layout shift during page load #83075
Labels
A-rustdoc-ui
Area: Rustdoc UI (generated HTML)
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
The top of a rustdoc page for a struct or trait always has
[+] Show declaration
at the top. This text is generated by main.js as part of building all the open/close toggles. Because it's built by JS, it comes in very late in the page load, which generates a noticeable layout shift.This is particularly noticeable on mobile, here the "Show declaration" text takes up a significant fraction of the screen.
One solution would be to render this text as part of the HTML, so it doesn't have to be generated by JS.
However, I'd like to propose a different fix: For structs and traits, remove "Show declaration" text, and the declaration behind it entirely. The same content is provided in more readable form in the "Fields", "Required methods," and "Provided methods" sections. For the user who wants a link near the top of the document to see the actual declaration as it would be written out in Rust, there's already the
[src]
link.This fix has the added advantage that besides removing a layout shift, it also reclaims some above-the-fold space for the documentation.
The text was updated successfully, but these errors were encountered: