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

Scripts not loading properly (Document Head Management) #3687

Open
johnyvelho opened this issue Mar 7, 2025 · 0 comments
Open

Scripts not loading properly (Document Head Management) #3687

johnyvelho opened this issue Mar 7, 2025 · 0 comments

Comments

@johnyvelho
Copy link

Which project does this relate to?

Router

Describe the bug

External scripts are not getting loaded when adding it through scripts/HeadContent/Scripts component.
<HeadContent /> and <Scripts /> components are rendered in the __root.tsx.

It only get loaded if the flag sync: true is added to the script. but doing it the script may not be ready when the page loads.

export const Route = createFileRoute('/onboarding/$participant_id/(nostepper)/signature/docusign')({
    component: DocusignSignaturePage,
    preload: false,
    loader: async ({ params, context }) => {
        const response = await signatureMutation(params.participant_id);

        if (response.error) {
            throw new Error('There was an error starting the signature process');
        }

        return {
            docusignUrl: response.data.url,
        };
    },
    head: () => {
        return {
            scripts: [
                {
                    src: 'https://js-d.docusign.com/bundle.js',
                },
            ],
        };
    },
});

minimal example: https://stackblitz.com/edit/tanstack-router-frejwjfz
discussion on discord: https://discord.com/channels/719702312431386674/1007702008448426065/threads/1347295057870454804

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-frejwjfz

Steps to Reproduce the Bug or Issue

  1. navigate to /about
  2. observe in the network events that bundle.js script from docusign is not getting loaded

Expected behavior

external scripts get loaded with/without async flag

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant