3 ms·
What if I want the website to work even when JavaScript is not turned on? I'd need a backend server and some frontend logic handling that case.
by sureglymop 3y ago
What if I want the website to work even when JavaScript is not turned on? I'd need a backend server and some frontend logic handling that case.
- iudqnolq 3y agoNot necessarily. It depends on what you need. For example suppose you were implementing an news reader with two panes. Left pane is a list of titles and previews, right pane is a full article for the selected item in the left pane. You can make the left pane a list of links to dedicated pages, and then add an htmx attribute to indicate that when the user has JavaScript to instead fetch a html snippet with just full article and swap it into the right pane. If you had a reasonably bounded set of articles you could statically generate all the /article/id.html and the /article/id/snippet.html files, though a backend probably makes sense.
- sureglymop 3y agoAt that point, how big is the difference really between sending the right pane only as opposed to the whole page performance wise? I'm just not sure if this approach is worth it for me.
- wishinghand 3y agoIn that case you need to have everything rendered server side and perhaps get creative with the usage of forms firing off events that can be intercepted by the server and then return a new page. Certain things like Nav menu drop downs and folding text can’t be done with native CSS and HTML.