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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/doc/rust.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@
font-style: normal;
font-weight: 400;
src: local('Fira Sans'), url("FiraSans-Regular.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Fira Sans';
font-style: normal;
font-weight: 500;
src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-style: normal;
font-weight: 400;
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-style: italic;
font-weight: 400;
src: url("SourceSerifPro-It.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-style: normal;
font-weight: 700;
src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Code Pro';
Expand All @@ -35,6 +40,7 @@
/* Avoid using locally installed font because bad versions are in circulation:
* see https://github.com/rust-lang/rust/issues/24355 */
src: url("SourceCodePro-Regular.woff") format('woff');
font-display: swap;
}

*:not(body) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ crate fn render<T: Print, S: Print>(
<div class=\"theme-picker\">\
<button id=\"theme-picker\" aria-label=\"Pick another theme!\" aria-haspopup=\"menu\">\
<img src=\"{static_root_path}brush{suffix}.svg\" \
width=\"18\" \
width=\"18\" height=\"18\" \
alt=\"Pick another theme!\">\
</button>\
<div id=\"theme-choices\" role=\"menu\"></div>\
Expand All @@ -102,7 +102,7 @@ crate fn render<T: Print, S: Print>(
<button type=\"button\" class=\"help-button\">?</button>
<a id=\"settings-menu\" href=\"{root_path}settings.html\">\
<img src=\"{static_root_path}wheel{suffix}.svg\" \
width=\"18\" \
width=\"18\" height=\"18\" \
alt=\"Change settings\">\
</a>\
</div>\
Expand Down
14 changes: 11 additions & 3 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
src: local('Fira Sans'),
url("FiraSans-Regular.woff2") format("woff2"),
url("FiraSans-Regular.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Fira Sans';
Expand All @@ -14,6 +15,7 @@
src: local('Fira Sans Medium'),
url("FiraSans-Medium.woff2") format("woff2"),
url("FiraSans-Medium.woff") format('woff');
font-display: swap;
}

/* See SourceSerifPro-LICENSE.txt for the Source Serif Pro license. */
Expand All @@ -22,18 +24,21 @@
font-style: normal;
font-weight: 400;
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-style: italic;
font-weight: 400;
src: local('Source Serif Pro Italic'), url("SourceSerifPro-It.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-style: normal;
font-weight: 700;
src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff');
font-display: swap;
}

/* See SourceCodePro-LICENSE.txt for the Source Code Pro license. */
Expand All @@ -44,12 +49,14 @@
/* Avoid using locally installed font because bad versions are in circulation:
* see https://github.com/rust-lang/rust/issues/24355 */
src: url("SourceCodePro-Regular.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
src: url("SourceCodePro-Semibold.woff") format('woff');
font-display: swap;
}

* {
Expand Down Expand Up @@ -129,7 +136,7 @@ h1, h2, h3, h4,
#source-sidebar, #sidebar-toggle,
/* This selector is for the items listed in the "all items" page. */
#main > ul.docblock > li > a {
font-family: "Fira Sans", sans-serif;
font-family: "Fira Sans", Arial;
}

.content ul.crate a.crate {
Expand Down Expand Up @@ -475,7 +482,7 @@ h4 > code, h3 > code, .invisible > code {
}
#main > .since {
top: inherit;
font-family: "Fira Sans", sans-serif;
font-family: "Fira Sans", Arial;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we keep sans-serif as Arial may not always be available?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds logical indeed. Want to send a PR for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's fixed. 7134b0e

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

}

.content table:not(.table-display) {
Expand Down Expand Up @@ -684,6 +691,7 @@ a {
width: calc(100% - 63px);
}
#crate-search {
min-width: 115px;
margin-top: 5px;
padding: 6px;
padding-right: 19px;
Expand Down Expand Up @@ -1293,7 +1301,7 @@ h4 > .notable-traits {

.help-button {
right: 30px;
font-family: "Fira Sans",sans-serif;
font-family: "Fira Sans", Arial;
text-align: center;
font-size: 17px;
}
Expand Down