Skip to content

Commit dac788f

Browse files
committed
rustdoc: reduce size of <head> with preload loop
1 parent 5f84f4b commit dac788f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/librustdoc/html/templates/page.html

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
<meta name="generator" content="rustdoc"> {# #}
77
<meta name="description" content="{{page.description}}"> {# #}
88
<title>{{page.title}}</title> {# #}
9-
<script> if (window.location.protocol !== "file:") document.write(` {# Hack to skip preloading fonts locally - see #98769 #}
10-
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_serif_4_regular}}"> {# #}
11-
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_regular}}"> {# #}
12-
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_medium}}"> {# #}
13-
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_regular}}"> {# #}
14-
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_semibold}}"> {# #}
15-
`)</script> {# #}
9+
<script>if(window.location.protocol!=="file:") {# Hack to skip preloading fonts locally - see #98769 #}
10+
for(f of "{{files.source_serif_4_regular}},{{files.fira_sans_regular}},{{files.fira_sans_medium}},{{files.source_code_pro_regular}},{{files.source_code_pro_semibold}}".split(",")) {# #}
11+
document.write(`<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}${f}">`) {# #}
12+
</script> {# #}
1613
<link rel="stylesheet" {#+ #}
1714
href="{{static_root_path|safe}}{{files.normalize_css}}"> {# #}
1815
<link rel="stylesheet" {#+ #}
@@ -114,13 +111,13 @@ <h2> {# #}
114111
<div class="version">{{+ display_krate_version_extra}}</div> {# #}
115112
{% endif %}
116113
{% else %}
117-
<div class="src-sidebar-title">
114+
<div class="src-sidebar-title"> {# #}
118115
<h2>Files</h2> {# #}
119116
</div> {# #}
120117
{% endif %}
121118
{{ sidebar|safe }}
122119
</nav> {# #}
123-
<div class="sidebar-resizer"></div>
120+
<div class="sidebar-resizer"></div> {# #}
124121
<main> {# #}
125122
{% if page.css_class != "src" %}<div class="width-limiter">{% endif %}
126123
<nav class="sub"> {# #}

0 commit comments

Comments
 (0)