Skip to content

Commit 90f7a0f

Browse files
committed
perf: content-visibility on snippets + stable min-heights (M6/M7)
M6: content-visibility:auto + contain-intrinsic-size on each snippet wrapper so off-screen snippets skip layout/paint (helps the many-frameworks worst case). M7: give the code editor body a min-height (h-40) and fix the loading skeleton's invalid h-164px to a matching h-40 so the skeleton->code swap doesn't shift (CLS).
1 parent f6cae9d commit 90f7a0f

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/lib/components/CodeEditor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<div class="relative group">
5353
<div
5454
bind:this={codeSnippetEl}
55-
class="bg-[#0d1117] px-4 py-3 text-sm overflow-auto rounded-b rounded-tr"
55+
class="bg-[#0d1117] min-h-40 px-4 py-3 text-sm overflow-auto rounded-b rounded-tr"
5656
>
5757
{#if snippet}
5858
<!-- eslint-disable-next-line svelte/no-at-html-tags -->

src/lib/components/Comparison.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
{#each snippets.filter((s) => s.sectionId === section.sectionId) as snippet (snippet.snippetId)}
279279
{@const snippetPathId = section.sectionId + "." + snippet.snippetId}
280280
<div
281+
class="snippet-cv"
281282
id={snippetPathId}
282283
data-snippet-id={snippetPathId}
283284
data-testid={`snippet-${snippetPathId}`}
@@ -391,7 +392,7 @@
391392
class="h-2.5 rounded-full bg-gray-700 w-10 animate-pulse"
392393
></div>
393394
</div>
394-
<div class="w-full h-164px bg-[#0d1117] px-4 py-7">
395+
<div class="w-full h-40 bg-[#0d1117] px-4 py-7">
395396
<div class="max-w-sm animate-pulse">
396397
<div class="h-3.5 rounded-full bg-gray-700 w-48 mb-4"></div>
397398
<div
@@ -448,4 +449,12 @@
448449
.header-anchor:hover > a {
449450
opacity: 1;
450451
}
452+
453+
/* M6: skip layout/paint for off-screen snippets (big DOMs with many
454+
frameworks). `auto` remembers the real size once measured; the estimate is
455+
a first-paint placeholder. The sticky title lives inside and keeps working. */
456+
.snippet-cv {
457+
content-visibility: auto;
458+
contain-intrinsic-size: auto 600px;
459+
}
451460
</style>

0 commit comments

Comments
 (0)