Skip to content

Commit a0328fc

Browse files
committed
perf(website): improved image performance
Turned them into JPGs that are *much* smaller, and added a gradient to the landing page that ensures text is visible even before image render (theoretically).
1 parent bb7c5a5 commit a0328fc

File tree

7 files changed

+11
-27
lines changed

7 files changed

+11
-27
lines changed

website/src/error_pages.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ fn not_found_page<G: Html>(
4545
span { ". If you came here another website, or a search engine, this page probably existed once, but has since been moved. Here are some pages you might like to try instead:" }
4646
ul(class = "pl-6 mt-1 w-full") {
4747
li {
48-
a(class = "underline text-indigo-500", href = "/") { "Home" }
48+
a(class = "underline text-indigo-500", href = "") { "Home" }
4949
}
5050
li {
51-
a(class = "underline text-indigo-500", href = "/docs") { "Docs" }
51+
a(class = "underline text-indigo-500", href = "docs") { "Docs" }
5252
}
5353
li {
54-
a(class = "underline text-indigo-500", href = "/comparisons") { "Comparisons" }
54+
a(class = "underline text-indigo-500", href = "comparisons") { "Comparisons" }
5555
}
5656
li {
57-
a(class = "underline text-indigo-500", href = "/plugins") { "Plugins" }
57+
a(class = "underline text-indigo-500", href = "plugins") { "Plugins" }
5858
}
5959
}
6060
}

website/src/templates/index.rs

+4
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,10 @@ pub fn head(cx: Scope) -> View<SsrNode> {
680680
view! { cx,
681681
title { (t!("perseus", cx)) }
682682
link(rel = "stylesheet", href = ".perseus/static/prism.css")
683+
// Prefetch the images and fonts so the browser gets on these as quickly as possible
684+
link(rel = "prefetch", href = ".perseus/static/mesh_open.jpg")
685+
link(rel = "prefetch", href = ".perseus/static/mesh_close.jpg")
686+
link(rel = "prefetch", href = ".perseus/static/cy-grotesk-grand-regular.woff2")
683687
}
684688
}
685689

website/static/mesh_close.jpg

286 KB
Loading

website/static/mesh_close.png

-2.27 MB
Binary file not shown.

website/static/mesh_open.jpg

265 KB
Loading

website/static/mesh_open.png

-2.18 MB
Binary file not shown.

website/static/styles/style.css

+3-23
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,6 @@ footer {
6868
}
6969
}
7070

71-
@media (prefers-color-scheme: light) {
72-
.mesh-open-bg {
73-
background-image: url("../mesh_open.png");
74-
background-size: cover;
75-
}
76-
.mesh-close-bg {
77-
background-image: url("../mesh_close.png");
78-
background-size: cover;
79-
}
80-
}
81-
@media (prefers-color-scheme: dark) {
82-
.mesh-open-bg {
83-
background-image: url("../mesh_open_dark.png");
84-
background-size: cover;
85-
}
86-
.mesh-close-bg {
87-
background-image: url("../mesh_close_dark.png");
88-
background-size: cover;
89-
}
90-
}
91-
9271
/* Styles for the Lighthouse report (mostly copied from Lighthouse itself for the animations etc.) */
9372
.font-mono-lh {
9473
font-family: 'Roboto Mono', 'Menlo', 'dejavu sans mono', 'Consolas', 'Lucida Console', monospace
@@ -145,7 +124,8 @@ input.search-bar-bg {
145124
}
146125
/* Styling for the background of each index page tile */
147126
.tile-start::before {
148-
background-image: url("../mesh_open.png");
127+
background: linear-gradient(157deg, rgba(148,160,235,1) 0%, rgba(206,121,195,1) 84%, rgba(227,127,188,1) 100%); /* This is a fallback so users can see the white text (esp. on slow networks) */
128+
background-image: url("../mesh_open.jpg");
149129
}
150130
.tile-state-generation::before {
151131
background-color: #7566e4;
@@ -160,7 +140,7 @@ input.search-bar-bg {
160140
background-color: #db80bd;
161141
}
162142
.tile-end::before {
163-
background-image: url("../mesh_close.png");
143+
background-image: url("../mesh_close.jpg");
164144
}
165145

166146
/* Tooltip handling */

0 commit comments

Comments
 (0)