Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to prevent preloading client-side scripts in next/document's Head #16853

Closed
callumlocke opened this issue Sep 4, 2020 · 3 comments
Closed

Comments

@callumlocke
Copy link
Contributor

callumlocke commented Sep 4, 2020

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 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.

@timneutkens
Copy link
Member

See #11949

Duplicate of #11949

@callumlocke
Copy link
Contributor Author

Thank you! That was quick

@balazsorban44
Copy link
Member

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 vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants