Skip to content

Commit 05d621c

Browse files
committed
perf(solid): check for a document after defining the truncation sweep
With the guard after the `sweep` closure, the minifier folds it into the dispatch (`typeof document<"u"&&(...)`) instead of an early `if(...)return;`: 7 B less minified in every hydrating scenario. This PR's growth drops from +25 B to +18 B minified, back inside the size gate's 20 B allowance on the three page scenarios that went over it.
1 parent a18099f commit 05d621c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎packages/solid/src/client/hydration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2659,7 +2659,6 @@ function subscribeFragments(cb: (id: string, parent?: ParentNode) => void): () =
26592659
// hand-built `_$HY`) nothing says the parser carried the records, and a late
26602660
// runtime stays out.
26612661
function watchTruncation(hy: any) {
2662-
if (typeof document === "undefined") return;
26632662
const sweep = () => {
26642663
if (!hy.r) return;
26652664
// First, before any boundary below resumes: a cut fragment's fresh
@@ -2682,6 +2681,7 @@ function watchTruncation(hy: any) {
26822681
// rejection.
26832682
setTimeout(() => rejectTruncatedRefs(consumed));
26842683
};
2684+
if (typeof document === "undefined") return;
26852685
if (document.readyState === "loading")
26862686
document.addEventListener("DOMContentLoaded", sweep, { once: true });
26872687
else if (hy.s) sweep();

0 commit comments

Comments
 (0)