1. 14
  1.  

  2. 6

    Random question. I like the concept of virtual DOM, but how does one handle the no JavaScript case?

    I’d like to have a nice fallback, but even if js is required for some interactions, rendering everything server side still wins imo for initial page view.

    One solution would be to run a vdom implementation server side. I assume that’s possible. But if my backend isn’t written in JavaScript now I have yet one more moving part.

    1. 11

      I think that you’ve successfully answered all of your own questions.

      1. 3

        Just to elaborate slightly on brandonbloom’s answer: you would indeed want to do the initial rendering pass on the server, if that’s where you want to go. You can take a look at http://augustl.com/blog/2014/jdk8_react_rendering_on_server/ for an example of how to do that on the JVM (i.e., you don’t have to bust out Node). Yes, this is another component, but it’s the way React intends for you to handle this problem.

        I’d note, on a personal level, that I no longer find any real value to designing for people who turn JavaScript off. They are an incredibly small part of the user base, they are shrinking, and they tend not to align with people who pay money for third-party hosted apps. I understand you wanting to design for yourself if you do run with JavaScript off, but I don’t think this is a common enough use case to actually worry about in most contexts.

        1. 3

          I’d like to avoid JavaScript for initial tender to avoid the flash of unstyled content, though perhaps better called the long pause of no content. For example, somebody at blogspot apparently decided it’d be ok to show me a blank loading screen for five seconds before showing me the plain text. Drives me nuts.

          Maybe I could avoid this through other means, but testing multiple browsers under a variety of network conditions seems like a lot more work than feeding the browser html to start.

          Also, call me old fashioned, but I still download a fair number of web pages with Python, or even the OpenBSD ftp client. I obviously don’t expect such pages to be fully interactive, but I do expect more than an empty shell with a script tag.

      2. 2

        I would love to see the core idea from this post rewritten using many other tools and environments (Polymer, Android apps, Swift MVC, etc).