10 votes

Topic deleted by author

6 comments

  1. [4]
    stu2b50
    Link
    I saw this on hackernews earlier and personally am pretty excited to try it out. I'm not sure when but I'll give this paradigm a spin the next time I'm writing a webapp. I would note that...

    I saw this on hackernews earlier and personally am pretty excited to try it out. I'm not sure when but I'll give this paradigm a spin the next time I'm writing a webapp.

    I would note that basically all the benefits are more for the developers than the end users. For instance, if you dislike how websites require JS to operate... this doesn't make that any better. If you have JS turned off, any "hotwire" site will be completely broken, since it requires a client-side JS library to coordinate wiring HTML to you.

    What it does make better is the developer experience. Writing a JAMstack style SPA is honestly quite tiring as a solo developer. A big hinderance is the fact that there's now a layer between your services and your client-side render. If you want to query the database for all the Restaurants, for instance, first you have to do that query on an API endpoint, then you have to serialize everything into JSON (etc), then you have parse that on the client side. You also have to worry about JSON schema now, and of course you loose all complex typing through that conversion.

    In comparison, in a traditional server-side rendered site, you just query the objects, pass it into your template, and you can use the objects as is. No extra parsing, no extra layer. But of course people expect a certain amount of dynamicity now.

    Tildes and hackernews is a good example. To make a new reply on hnews, you have to go onto a separate page, which is just a textbox and submit button. Tildes has just a bit of JS so that you can stay on the page at the same time.

    6 votes
    1. [2]
      zlsa
      Link Parent
      I don't have any experience with Hotwire, but I would expect websites using it could be designed so most features would fallback to regular HTML if JS isn't available.

      I don't have any experience with Hotwire, but I would expect websites using it could be designed so most features would fallback to regular HTML if JS isn't available.

      1 vote
      1. stu2b50
        Link Parent
        Hm, I doubt so, or at least in a significantly easier manner. For one, on the server side there's not really a good way to check if the browser making the request has JS enabled or not. So you'd...

        Hm, I doubt so, or at least in a significantly easier manner. For one, on the server side there's not really a good way to check if the browser making the request has JS enabled or not.

        So you'd have to hide an entire page worth of HTML inside the html for your SPA, that has to interact with Turbo (or whatever blob of Hotwire dom management you use) so if JS is disabled it instead shows the normal page. Which is not exactly elegant and has more bloat really. Or you could have a link to the server-side rendered page.

        Secondly, your server is still setup to send over HTML snippets over websockets. While it is easier to take those and stick in a template than if you just sent JSON, it's still effectively managing two sites.

        And there's other stuff, like in a SPA tabs are handled via client-side routing, but if you want to maintain a static verison as well, you'd have to setup all the logic with urls and routing on your server.

        I suppose it's mildly better than if you were sending JSONs or protobufs to maintain a second version of your site but it's not exactly easy either.

        2 votes
    2. teaearlgraycold
      Link Parent
      If something like this becomes popular and standard enough it could just become an HTML6 feature, removing the need for the client library and JS entirely.

      If something like this becomes popular and standard enough it could just become an HTML6 feature, removing the need for the client library and JS entirely.

  2. dblohm7
    Link
    ELI5: Is this basically (near) server-side rendering for SPAs?

    ELI5: Is this basically (near) server-side rendering for SPAs?

    2 votes
  3. Deimos
    Link
    DHH made a blog post about it today: HTML over the wire

    DHH made a blog post about it today: HTML over the wire

    2 votes