Skip to content

Commit

Permalink
Seeing if this improves performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 17, 2024
1 parent 90616cc commit 36bf01c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions site/client.tsx → site/highlight-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ const highlighter = await createHighlighter({
});

for (const sample of document.querySelectorAll<HTMLElement>('.sample')) {
import(`./samples/${sample.dataset['sample']}.js`).then(mod => {
sample.querySelector('.sample-output')!.append(<mod.default />);
});

const pre = sample.querySelector('pre')!;
pre.outerHTML = highlighter.codeToHtml(pre.textContent!, {
lang: 'tsx',
Expand Down
3 changes: 2 additions & 1 deletion site/index.html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export default <>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel='stylesheet' href='style.css' />
<script type='module' src='client.js' />
<script type='module' src='load-samples.js' />
<script type='module' src='highlight-code.js' />
<title>Vanilla JSX</title>
</head>
<body>
Expand Down
5 changes: 5 additions & 0 deletions site/load-samples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
for (const sample of document.querySelectorAll<HTMLElement>('.sample')) {
import(`./samples/${sample.dataset['sample']}.js`).then(mod => {
sample.querySelector('.sample-output')!.append(<mod.default />);
});
}

0 comments on commit 36bf01c

Please sign in to comment.