feat:Actually ship no JS by default (#3696)
In many places, Fresh marketing claims the framework ships no JS by default, **this was false**. This PR reworks core parts of the framework to check whether JS is needed on the client with these criteria: 1. Use of islands 2. Use of Partials (`f-client-nav`) If either of those those criteria are met, JavaScript will be loaded as normal, but if both are false, then the `client-entry` script is omitted from the page. Fixes https://github.com/denoland/fresh/issues/3662 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Bartek Iwańczuk
Claude Opus 4.6
parent
8b0d42b82a
commit
6dd2c97fb2
@@ -302,6 +302,7 @@ function isJsMediaType(media: MediaType): boolean {
|
||||
case MediaType.Unknown:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export type DenoSpecifier = string & { __deno: string };
|
||||
|
||||
@@ -203,7 +203,10 @@ Deno.test({
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
|
||||
await page.locator("style[data-vite-dev-id$='style.css']").wait();
|
||||
// Vite 6: data-vite-dev-id; Vite 7+: vite-module-id on injected style.
|
||||
await page.locator(
|
||||
"style[data-vite-dev-id$='style.css'], style[vite-module-id]",
|
||||
).wait();
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -221,7 +224,9 @@ Deno.test({
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
|
||||
await page.locator("style[data-vite-dev-id$='style.css']").wait();
|
||||
await page.locator(
|
||||
"style[data-vite-dev-id$='style.css'], style[vite-module-id]",
|
||||
).wait();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user