-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Make <Scripts> render nothing on the client #390
Conversation
Hi @developit, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected]. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
One way to don't ship Script to browser would be to create a folder with the server and browser implementations and a package.json with the main and browser keys pointing to each one. |
I think this would be performance regression because remix/packages/remix-react/components.tsx Lines 755 to 776 in 2facf69
Without that, when we dynamically So it's not just a server thing, it matters for client transitions too. We already memoize the initial remix/packages/remix-react/components.tsx Lines 702 to 741 in 2facf69
So it's not clear to me what problem we have and what this PR is attempting to solve? Please re-open (but include the module preloads ofc) if I'm missing something :) |
This makes
<Scripts>
do nothing on the client. In Preact, the mismatched<script>
and<link>
tags in the SSR'd HTML will be skipped over during hydration, and I'm fairly certain this is also the case in React.The existing implementation could be further simplified now that useMemo() is no longer needed to prevent reinsertion of scripts after hydration. Also, if there's a compile-time equivalent of the
typeof document !== 'undefined'
check (process.browser
is a common constant in build systems), that would make it possible to avoid shipping<Scripts>
to the client at all.