-
Notifications
You must be signed in to change notification settings - Fork 222
Closed
Labels
Description
Is your feature request related to a problem?
This code for appending script tags is too smart:
| const scripts = document.querySelectorAll('body > script') | |
| if (scripts.length > 0) { | |
| scripts[0].parentNode?.insertBefore(scriptTag, scripts[0]) | |
| } else { | |
| // In exceptional situations this call might load before the DOM is fully ready. | |
| document.body.appendChild(scriptTag) | |
| } |
It causes a hydration error because it interweaves with this component in tanstack router.
Describe the solution you'd like
- allow a configuration to always
document.body.appendChild(scriptTag) - allow a configuration to set the target element (so i can set it to document.body)
- allow
prepare_external_dependency_scriptto return a promise so the configuration can customize how the script is mounted instead of disabling it.
Describe alternatives you've considered
current solution is patching posthog to make the script loading simpler
Related sub-libraries
- posthog-js (web)
Additional Notes
search keywords: hydration error, tanstack start, tanstack router, loadScript
Reactions are currently unavailable