Allow <noscript> in Vue templates for SSR usage
See original GitHub issueVersion
2.5.17
Reproduction link
https://codepen.io/brophdawg11/pen/OBdZyX
Steps to reproduce
I’m opening this issue as a follow up to https://github.com/vuejs/vue/issues/8247, as I don’t think the solution provided there is suitable for all use-cases. In a fairly simple UI, where everything is relatively positioned and flows downward, it would likely be fine to include <noscript>
outside the context of the Vue application, and it would render correctly above the entire app.
However, there are plenty of other UI’s that it may not be desirable or feasible to include <noscript>
outside of the Vue application context and display it properly. The linked codepen shows a simple fixed-header layout, where including the <noscript>
tag outside the Vue application context results in the <noscript>
tag being hidden behind the fixed header, where in reality it is intended to be rendered inside the main body content, and thus below the fixed header.
The <noscript>
outside the Vue context also has the unintended effect of pushing down the main content, which has a proper margin-top to account for the static-height fixed header.
Per MDN, <noscript>
is Flow Content (https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Flow_content), it is perfectly viable to exist outside the <head>
(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript), and is perfectly valid to nest inside the DOM in a <div>
, as div’s allow Flow Content as their children (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div).
Please reconsider the decision to not permit noscript
tags in Vue templates.
What is expected?
<noscript>
elements should render properly in Vue templates
What is actually happening?
<noscript>
elements do not render properly in Vue templates and cause hydration issues when in SSR
Issue Analytics
- State:
- Created 5 years ago
- Reactions:31
- Comments:30
Top GitHub Comments
@alexbruno It makes sense to have noscript in component in some case : like SEO (one of the main purpose of SSR provided by Vue).
If you lazy-loading image you can have a component like that :
In this case it’s important for the
img
tag contain in noscript to be at this place for better UI integration.In fact,
noscript
is like an HTML native hack in modern web! For today web apps, disabled JS is very uncommon.