Commit 3e74810
MAINT - Defer FontAwesome script to improve performance (#2209)
This pull request:
- Adds "defer" attribute to the script tag that loads the FontAwesome
library
- Consolidates our two custom icon files into one and also loads them
with defer
- Updates documentation to reflect the above two changes
- Excludes images.html from the list of Kitchen Sink pages to check with
Lighthouse.
### Defer
> [!WARNING]
> When this pull request gets released in the next version of the PyData
Sphinx Theme, it will require theme users to update their custom icon
entries in `html_js_files` to include the `defer` attribute (see the
update to the docs page in this pull request).
Without the defer attribute, the entire page has to wait for the
FontAwesome script to be downloaded and executed. Lighthouse identified
this script as the worst offender. With the defer attribute, the page
should be able to load faster.
### Excluding images.html
The reason I'm excluding images.html from Lighthouse is because it
contains images that are hotlinked from Picsum. I think that this is the
reason the Lighthouse performance score comes in too low (below 80).
Because when I examined the Lighthouse report for that page, I saw the
main reason the page failed was because of a slow Largest Contentful
Paint, and when digging into that, the report showed the following
table:
Phase | % of LCP | Timing
-- | -- | --
TTFB | 8% | 460 ms
Load Delay | 89% | 5,350 ms
Load Time | 2% | 110 ms
Render Delay | 2% | 100 ms
I assume that most of that load delay has to do with hotlinking from
Picsum and nothing that we can fix without modifying the Kitchen Sink
pages, which we're not supposed to do since those are generated from a
script.
Using the [Lighthouse score
calculator](https://googlechrome.github.io/lighthouse/scorecalc/#FCP=1665&LCP=6016&TBT=54&CLS=0&SI=2861&TTI=6045&device=mobile&version=12.1.0),
if I substract 5,000 ms from Largest Contentful Paint, the performance
score climbs to 99, which puts it in line with the new performance
scores for the other Kitchen Sink pages.
On the flip side, even though this PR excludes images.html from
Lighthouse, it actually adds more Kitchen Sink pages to the Lighthouse
audit because previously only 5 pages were being checked because the
[default for
maxAutodiscoverUrls](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md)
is 5.
### How I checked this PR
- [x] Looked at the results on the lighthouse-audit CI job
- Inspected the two custom icons in the preview build
- [x] Brave browser, desktop mode
- [x] Brave browser, mobile mode
- [x] Safari, desktop mode
- [x] Firefox, desktop mode
- [x] Checked the preview build to make sure there were no new
JavaScript or other errors in the browser dev tools console log.
- [x] Checked the updated [Header Links docs
page](https://pydata-sphinx-theme--2209.org.readthedocs.build/en/2209/user_guide/header-links.html)
in the preview build
---------
Co-authored-by: Tania Allard <[email protected]>1 parent 6e536c2 commit 3e74810
File tree
6 files changed
+75
-51
lines changed- .github/workflows
- docs
- _static
- user_guide
6 files changed
+75
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
Lines changed: 24 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | 1 | | |
5 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
16 | 30 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
261 | 263 | | |
262 | 264 | | |
263 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
223 | 225 | | |
224 | | - | |
| 226 | + | |
225 | 227 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
229 | 233 | | |
230 | | - | |
| 234 | + | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
236 | | - | |
| 240 | + | |
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
240 | 256 | | |
241 | 257 | | |
242 | 258 | | |
| |||
254 | 270 | | |
255 | 271 | | |
256 | 272 | | |
257 | | - | |
| 273 | + | |
258 | 274 | | |
259 | 275 | | |
260 | 276 | | |
| |||
309 | 325 | | |
310 | 326 | | |
311 | 327 | | |
| 328 | + | |
| 329 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
0 commit comments