You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Occasionally, I want to omit all client-side JavaScript on certain pages. I still want to be able to use JSX components to render the HTML (either via static export or SSR), but I don't want to hydrate the app on the client at all.
So I write a custom Document that conditionally omits the <NextScript /> element for certain pages.
But when I do this, the default <Head /> still renders various <link rel="preload"> links for various JS files. So the scripts are still downloaded even though they are never executed, wasting bandwidth.
Describe the solution you'd like
The ability to disable preload links by setting a prop on the Head component from next/document.
Describe alternatives you've considered
I could omit the <Head /> entirely and write my own <head>...</head>, omitting preload link elements, but that would mean losing the other functionality of Head.
Maybe the official Head could include some magic that automatically prevents link[rel=preload] elements being rendered if the parent Document doesn't also include a <NextScript />. That might sound a bit clever, but maybe it's the right approach logically.
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Jan 29, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Feature request
Is your feature request related to a problem? Please describe.
Occasionally, I want to omit all client-side JavaScript on certain pages. I still want to be able to use JSX components to render the HTML (either via static export or SSR), but I don't want to hydrate the app on the client at all.
So I write a custom
Document
that conditionally omits the<NextScript />
element for certain pages.But when I do this, the default
<Head />
still renders various<link rel="preload">
links for various JS files. So the scripts are still downloaded even though they are never executed, wasting bandwidth.Describe the solution you'd like
The ability to disable preload links by setting a prop on the
Head
component fromnext/document
.Describe alternatives you've considered
I could omit the
<Head />
entirely and write my own<head>...</head>
, omitting preload link elements, but that would mean losing the other functionality ofHead
.Maybe the official
Head
could include some magic that automatically preventslink[rel=preload]
elements being rendered if the parentDocument
doesn't also include a<NextScript />
. That might sound a bit clever, but maybe it's the right approach logically.The text was updated successfully, but these errors were encountered: