SSR does not work when javascript is disabled
Asked Answered
P

2

5

Referring to this ticket here: https://github.com/zeit/next.js/issues/4210 I'm currently wondering why when you disable javascript, most of the content using relay modern and NextJS does not work.

My initial guess is that since NextJS is a React library for server-side rendering, if JavaScript is disabled in chrome, then obviously React does not work. However, NextJS is server-side rendering so therefore disabling javascript on the client side should not be a problem? Therefore, why does this problem still occur?

Penalty answered 22/1, 2019 at 17:1 Comment(0)
J
6

In a modern SSR scenario, as in an isomorphic application, only the first rendering is done by the server, that returns plain html content together with the js's that will be used for the subsequents rendering.

In case the browser has javascript disabled you should be seeing only the first rendering as a static page, since what the interpreter does is showing a plain html content, but then you shouldn't be able to interact with the page (that would require js to be enabled)

Jannery answered 22/1, 2019 at 17:17 Comment(3)
Is there anyway to still interacting with the page after the first render even if JS is disable?Marcasite
if JS is disable the page is a static html so basically no, in this scenario there's no way to interact with the pageJannery
The correct answer should be yes, you are able to interact with the page when javascript is disabled, but you need to use the correct html/http constructs. For example, make sure that all your form tags have the method and action attributes. For drop-downs, make sure you have associated buttons that post back to the server if you want to change the UI based on the dropdown value. You'll have to deal with the duplication of code and logic but that is the tradeoff if you want to support browsers with javascript disabled.Sketchbook
O
2

While @Karim's answer is correct, it is worth pointing out that a user can, technically speaking, partially interact with the page if you use "progressive enhancement". In this case, you use native HTML features to perform operations such as navigation to other pages, form submission, etc. Those do not require JS to be enabled to work correctly. Depending on your target audience, this might be more pain than its worth.

Opposite answered 16/8, 2020 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.