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

allow disabling client-side JS entirely #14765

Closed
1 task done
danielroe opened this issue Sep 2, 2022 · 10 comments · Fixed by nuxt/framework#7248
Closed
1 task done

allow disabling client-side JS entirely #14765

danielroe opened this issue Sep 2, 2022 · 10 comments · Fixed by nuxt/framework#7248

Comments

@danielroe
Copy link
Member

danielroe commented Sep 2, 2022

For some use cases, users may wish to have a purely HTML + CSS website where interactivity is not required. Shipping JS to hydrate such a site is unneeded.

For these use cases, we could consider support a top level option (or a per-path route rule) to disable rendering JS preload hints + script tags within the renderer.

Some initial steps:

Note: We may also need to update https://github.com/nuxtlabs/vue-telescope-api to accurately detect Nuxt on such sites. At the moment, it is unaware that https://nuxt.new/ is built with Nuxt 😆

@pi0
Copy link
Member

pi0 commented Sep 2, 2022

Pure HTML is not a normal output mode. We were considering it with @Atinux since Nuxt 2 but finally decided to not introduce but i really love this idea specially combined with reactive component islands. We can probably have a module to try this mode ahead of time. Later can be joined with route rules to set per page (or group of pages) bases.

Also good point about detection! What about a magical <-- nuxt --> comment replacing strings. (There is also X-Powered-By header but not working for static builds)

@516310460
Copy link
Contributor

516310460 commented Sep 2, 2022

This is great, just like building islands, non-interactive and interactive loading of js scripts.

This will improve very high performance and resource size.

@harlan-zw
Copy link
Contributor

It'd be great to see it in the core with some sort of support for island hydration

@516310460
Copy link
Contributor

It'd be great to see it in the core with some sort of support for island hydration

Yes, this is the beginning of a revolution

@HelloAlexPan
Copy link

This would be the key feature for us not to switch to Astro

@miclgael
Copy link
Contributor

miclgael commented Sep 5, 2022

I have written post-build hacks to do this in nuxt 2 and it is a real pain point. Kudos @danielroe

@516310460
Copy link
Contributor

Support nuxt2?

@danielroe
Copy link
Member Author

You can do this in Nuxt 2 by setting render.injectScripts to false.

@kstraszewski
Copy link

The feature looks great, it would be amazing to use it per route!

@ManasMadrecha
Copy link

ManasMadrecha commented Sep 20, 2022

Having absolutely no JS is not useful; we need some JS in header or in button to toggle dark mode.

It would be better to have this feature per component, like in Astro. By default, global setting will render no JS, but with JS option set in particular component, Nuxt could enable JS for only those components.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants