Isomorphic JS stacks allow you to have your MVC structure run on either the server or the client without modification.
This allows you to render the page on the server rather than the client which is useful for 1. the first page of a single page app and 2. as a fallback for users who either A. request the non-JS flow, or B. show up with browsers you don't want to support and can be sent down the non-JS flow instead, or C. when your JS fails for whatever reason (network failures, uncaught JS errors in production, etc).
The idea is that anything built on the web platform that doesn't have a very good reason for a hard JS dependency shouldn't have one, but instead should add the JS flair progressively on top of semantic HTML. Today's crop of big monoframeworks (like Angular) make this very difficult if not impossible to do. As such, I tend to avoid them as a rule unless my target runtime environment explicitly guarantees JS availability.
Unfortunately, it seems like most consumers of such frameworks don't apply such rigor in their "which tool is right for my job" evaluations.
Ah, thank you for that very clear explanation. In a perfect world, I would love to be able to apply those considerations to the end, but clients have not an extended budget and, when explained why it could be important, and how much is gonna cost more, the answer is always something along "I don't give a shit", more or less vulgar, depending on the client and the professional level we're on.
As the guy who makes all the technical decisions in the company, I set up a few ground rules though :
users who don't have JS can go to hell (and we won't even miss them
user with unsupported browsers can go to hell (and we won't even miss them
Right now, the lowest browser we cater for is IE 8. Under this, we thank the client for his time and wish him all the best with his project.
That being said, you can do it in Angular, but it indeed requires a bit of pushing things around (ie, you need to push this data in JS, either with a directive or in a script tag, and then send/retrieve/communicate this with the controller, which usually makes you break the purity of MVC. But as far as I love staying pure, our goal is to ship products in time, no the be an ayatollah. Sometimes you need to know when to close a sad eye on a bad practice).
I don't see how that justifies saying a JS dependency is the result of not applying rigor.
I have an ecommerce site with a hard JS dependency because the potential for loss is very small (no paying customer in the 2 years leading up to the project had javascript disabled), the potential to make money using the hard JS dependency was great, and the cost of development without the hard JS dependency was prohibitive. I could lose opportunity, lose money, or have a hard JS dependency and make money.
Does that justify a JS dependency? Yes, absolutely. How many people that have a hard JS dependency go through the steps to determine whether its the right choice? I don't know.
That's why I don't assume that most developers that institute a hard JS dependency are simply doing their jobs wrong.
On the contrary, not using progressive enhancement on something as simple as an e-commerce site comes with real costs. You will inevitably lose customers along this flow chart: http://kryogenix.org/code/browser/everyonehasjs.html
It's not a myth when a real world scenario is involved that says it's better to do the hard JS dependency. My actual costs are not an academic topic.
The flow chart you posted is a great example. I can go through it and look at the impact of those things on my site and then look at the potential result in lost customers. And, here's the thing, it still makes sense to do the hard JS dependency.
I get what you're trying to do. You're trying to say your academic approach beats a thorough investigation of a real world situation.
But it doesn't. That's the simple fact. The myth here is that a bunch of people talking about their limited experience on the internet can determine the best course of action for everybody else, regardless of the use case.
Although that's not even really the case because the links you posted mostly point out the fact that there are going to be exceptions when the hard JS dependency is necessary.
I have read them. They give great reasons to focus on PE and I do PE on most websites. The site I'm currently working on uses React with server side rendering and it's a dream. The load times are tiny even in worst case scenarios and I've been able to port a large-ish, customer owned, client-side javascript library from a previous web app into it and it's become completely usable even with javascript disabled.
For that project it makes absolute sense.
There exists use cases where it doesn't. I know you believe you already know every use case there could be. But, I'll bow out as well. I can't figure out this damn-all-the-use-cases-and-costs mentality you're pushing. It's just completely closed-minded.
You believe the idea that it can be too expensive to do PE is a myth. It isn't.
You believe most people that don't do PE aren't doing their job right. I pointed out that you have to assume a lot to say this.
Here's a particular situation:
A company is 1 year in to a 3 year project to redesign, build, test, and launch their website. They have a legacy site in ASP and a set of legacy systems connected to it for inventory management, CRM, etc.
They have a lucrative stock of products that they want to sell immediately. The products have a complex set of configurations and they want real-time display of how the parts combine into a finished product.
No suitable libs can be found to provide server side rendering of the javascript code that must run in the browser to make it run asynchronously. In this specific case, there must be a completely different server side code base developed to enable PE. Given a cost to implement and an estimate of how much business may be lost not implementing it, the best bet is to skip PE and rely on JS.
There are no plans to revisit the project once the new site is done because it's a one time buy out of stock from a company that went out of business so the product line won't be around 2 years in the future. Anything at the end of the FY is being written off.
Waiting 2 years for a modern site isn't an option. Spinning up a separate server to host just the app would be a huge mistake because of how much would have to be constructed to integrate it into the existing site's inventory management and CRM functions.
There's a limited expected pay out as a direct result of the app and that dictates the budget.
In this case, PE would be a mistake.
The use case says "skip PE" and the costs say "skip PE" because there are times when PE costs too much and is too difficult to implement.
The site I'm working on right now, as I said, uses server side rendering and works fine even over slow connections and with JS disabled. And it's wonderful to be in a situation where that's possible. But to say it's possible in all situations, even ones you don't know anything about, that's telling the world "I don't care about your use cases or costs, you should do it how I say or you aren't doing your job right."
But this was probably all a waste of time because you'll bow out because my use case is too close to the edge or something like that and you'll probably continue to tell people that it's a myth that PE can be too expensive, even if you have no idea what their case is and their case might actually be too expensive. You don't know, but what does that matter?
Do you know of any good open-source examples of isomorphic apps? I agree with the premise that apps should work without JS and just use JS to enhance the user experience. I've been doing this lately with Rails and Backbone, but my issue is I find myself duplicating a lot of server-side logic on the client.
I've yet to see a mainstream stack do it well. I also tried the Backbone method once and found it wanting. Better than not going isomorphic though. Seems like the best way to do isomorphic stuff is an area of active research. I hear good things from the React crowd, but I've yet to try it.
If I was building a fresh app today, I'd go with Express on the server, page.js on the client, and share controllers with this page.js plugin I wrote. This approach will work with any templating system that's compatible with Express (so pretty much any JS templating system).
Thank you. I'll probably try these out on my next project. It's an interesting topic because like you said it's still being researched and I haven't really seen it done in an elegant way.
To clarify, it can certainly be done well with a collection of smaller tools / micro libraries like the ones I linked.
I just have yet to see a large stack emerge which does it well. The big ones (e.g. Angular, Ember, React, etc) are all getting closer, but none are there yet. That's why I tend to avoid them for now except in situations where JS availability is guaranteed by the runtime environment.
4
u/kethinov May 27 '15
Isomorphic JS stacks allow you to have your MVC structure run on either the server or the client without modification.
This allows you to render the page on the server rather than the client which is useful for 1. the first page of a single page app and 2. as a fallback for users who either A. request the non-JS flow, or B. show up with browsers you don't want to support and can be sent down the non-JS flow instead, or C. when your JS fails for whatever reason (network failures, uncaught JS errors in production, etc).
The idea is that anything built on the web platform that doesn't have a very good reason for a hard JS dependency shouldn't have one, but instead should add the JS flair progressively on top of semantic HTML. Today's crop of big monoframeworks (like Angular) make this very difficult if not impossible to do. As such, I tend to avoid them as a rule unless my target runtime environment explicitly guarantees JS availability.
Unfortunately, it seems like most consumers of such frameworks don't apply such rigor in their "which tool is right for my job" evaluations.