Skip to content

Commit 46ccff3

Browse files
fix: disable client-side <Head>component until perf issue is fixed (#3255)
Need to look at it in more detail tomorrow.
1 parent 8717fb8 commit 46ccff3

2 files changed

Lines changed: 47 additions & 40 deletions

File tree

packages/fresh/src/runtime/client/preact_hooks_client.ts

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,53 +37,56 @@ options.vnode = (vnode) => {
3737
case "base":
3838
case "noscript":
3939
case "template":
40-
// deno-lint-ignore no-explicit-any
41-
vnode.type = (props: any) => {
42-
useEffect(() => {
43-
const text = renderToString(h(Fragment, null, props.children));
44-
45-
if (originalType === "title") {
46-
document.title = text;
47-
return;
48-
}
49-
50-
let matched: HTMLElement | null = null;
51-
if (vnode.key) {
52-
matched = document.head.querySelector(
53-
`head [data-key="${vnode.key}"]`,
54-
) as HTMLElement ?? null;
55-
}
56-
57-
if (matched === null && props.id) {
58-
matched = document.head.querySelector(
59-
`#${props.name}`,
60-
) as HTMLElement ??
61-
null;
62-
}
63-
64-
if (matched === null) {
65-
if (originalType === "meta") {
40+
// deno-lint-ignore no-constant-condition
41+
if (false) {
42+
// deno-lint-ignore no-explicit-any
43+
vnode.type = (props: any) => {
44+
useEffect(() => {
45+
const text = renderToString(h(Fragment, null, props.children));
46+
47+
if (originalType === "title") {
48+
document.title = text;
49+
return;
50+
}
51+
52+
let matched: HTMLElement | null = null;
53+
if (vnode.key) {
6654
matched = document.head.querySelector(
67-
`head [name="${props.name}"]`,
55+
`head [data-key="${vnode.key}"]`,
6856
) as HTMLElement ?? null;
69-
} else if (originalType === "base") {
70-
matched = document.head.querySelector(originalType) ?? null;
7157
}
72-
}
7358

74-
if (matched === null) {
75-
matched = document.createElement(originalType);
76-
}
59+
if (matched === null && props.id) {
60+
matched = document.head.querySelector(
61+
`#${props.name}`,
62+
) as HTMLElement ??
63+
null;
64+
}
7765

78-
if (matched.textContent !== text) {
79-
matched.textContent = text;
80-
}
66+
if (matched === null) {
67+
if (originalType === "meta") {
68+
matched = document.head.querySelector(
69+
`head [name="${props.name}"]`,
70+
) as HTMLElement ?? null;
71+
} else if (originalType === "base") {
72+
matched = document.head.querySelector(originalType) ?? null;
73+
}
74+
}
75+
76+
if (matched === null) {
77+
matched = document.createElement(originalType as string);
78+
}
79+
80+
if (matched.textContent !== text) {
81+
matched.textContent = text;
82+
}
8183

82-
applyProps(props, matched);
83-
}, []);
84+
applyProps(props, matched);
85+
}, []);
8486

85-
return null;
86-
};
87+
return null;
88+
};
89+
}
8790
break;
8891
}
8992
}

packages/fresh/tests/head_test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Deno.test("Head - ssr - merge keyed", async () => {
152152
});
153153

154154
Deno.test({
155+
ignore: true, // Temporarily until client perf is fixed
155156
name: "Head - client - set title",
156157
fn: async () => {
157158
const applyCache = await buildProd({
@@ -181,6 +182,7 @@ Deno.test({
181182
});
182183

183184
Deno.test({
185+
ignore: true, // Temporarily until client perf is fixed
184186
name: "Head - client - match meta",
185187
fn: async () => {
186188
const applyCache = await buildProd({
@@ -225,6 +227,7 @@ Deno.test({
225227
});
226228

227229
Deno.test({
230+
ignore: true, // Temporarily until client perf is fixed
228231
name: "Head - client - match style by id",
229232
fn: async () => {
230233
const applyCache = await buildProd({
@@ -269,6 +272,7 @@ Deno.test({
269272
});
270273

271274
Deno.test({
275+
ignore: true, // Temporarily until client perf is fixed
272276
name: "Head - client - match key",
273277
fn: async () => {
274278
const applyCache = await buildProd({

0 commit comments

Comments
 (0)