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

Script added in manual mode even if DelayHydration component is not used #56

Closed
sauravbv opened this issue Aug 16, 2024 · 3 comments
Closed

Comments

@sauravbv
Copy link
Contributor

sauravbv commented Aug 16, 2024

Description

Some help or suggestions are required so I can work on the code changes and raise a PR for this.
I have tried few ways in the package by setting a global state variable in the DelayHydration.mjs but does not work.
Happy to discuss more

The delay hydration and replayClick scripts are added to the rendered HTML even if the <DelayHydration> component is not used.
I have a use case where I am wrapping the entire page layout with based on a condition (Check attached screenshot)
When the v-else part is rendered the scripts are still added to the HTML output from nitro.
This is a problem especially when replayClick is enabled and causes the scroll touchEvent issue on mobile devices which was reported below
#54
#47

To Reproduce
Steps to reproduce the behavior:
Please check the below stackblitz
https://stackblitz.com/edit/nuxt-starter-8agcnh?file=app.vue
Manual mode and is not used, but the scripts is being injected and replayClick is triggering due to this

Expected behavior
If the mode is manual and the component is not used, delay hydration scripts shouldn't be appended in the nitro plugin.

Screenshots
image

Additional context
I have tried with some code changes in the package where I wanted to set a global state in the DelayHydration.mjs based on which scripts are appended or not in the nitro plugin.
Include or exclude filters won't help here as its a common page and delay hydration is toggled based on a condition.

@sauravbv sauravbv changed the title Delay hydration scripts added even if no DelayHydration component Script added in manual mode even if DelayHydration component is not used Aug 16, 2024
@sauravbv
Copy link
Contributor Author

@harlan-zw any suggestions / update on this?

@harlan-zw
Copy link
Owner

harlan-zw commented Sep 2, 2024

Hey, thanks for the detailed issue.

I've pushed up a fix in v1.3.7, I think this is the easiest way to solve the issue.

Let me know if you have any issues with it.

@sauravbv
Copy link
Contributor Author

sauravbv commented Sep 2, 2024

Thank you @harlan-zw
I will test it out and reply here.

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

2 participants