Skip to content

Commit 17c864e

Browse files
committed
Massively simplify off-screen nav’s lazy paint
1 parent 46b635d commit 17c864e

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

_layouts/default.html

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,24 @@
3131
});
3232
</script>
3333

34-
<script>
34+
<style>
35+
3536
/**
3637
* The site nav has been explicitly ‘turned off’ with `content-visibility:
3738
* hidden;` in its component (S)CSS file. This means we don’t need to bother
3839
* rendering it at all on the first pass: it’s off-screen anyway. Once we’re
39-
* approaching `domInteractive` (that’s now), we turn it ‘back on’. It’s
40-
* wrapped in a rAF to make it asynchronous, which is probably a bit of
41-
* a micro-optimisation.
40+
* approaching `domInteractive` (that’s now), we turn it ‘back on’. This
41+
* prioritises the painting of on-screen or above-the-fold content ahead of
42+
* an off-screen nav drawer.
4243
*/
43-
requestAnimationFrame(() => {
44-
const siteNavList = document.getElementById('jsSiteNavList');
45-
siteNavList.style.contentVisibility = 'visible';
46-
});
4744

48-
const navReady = performance.mark('navReady');
45+
.site-nav__list {
46+
content-visibility: visible;
47+
}
4948

50-
//# sourceURL=nav-visibility.inline.js
51-
</script>
49+
/*# sourceURL=nav-visibility.inline.css */
5250

53-
<noscript>
54-
<!--
55-
- In the highly unlikely event that someone has disabled JS, turn the nav
56-
- ‘back on’ synchronously.
57-
-->
58-
<style> .site-nav__list { content-visibility: visible; } </style>
59-
</noscript>
51+
</style>
6052

6153
<script type=speculationrules>
6254
{

0 commit comments

Comments
 (0)