Stop writing stateful HTML
colorglare.com
colorglare.com
Aaand that's where I stopped reading. Try not to kick your articles off with dogmatic statements like this and, if you have to, at least make sure they're factual.
In this case the background image adds absolutely nothing to the user experience or conveys what the content is about, if anything its quite an example of bad design and interferes with the user for no good reason! The "web developer" has added it just because he could not because there is any good and thought out reason to use this "image page monstrocity"
This is my personal website. I also use it to showcase my photographs. I agree that they don't add anything to the content.
Its just funny seeing same mistakes being repeated and various "trends" employed by web developers for no good reason other than "because we can, and it looks cool", but thats ok for personal projects since you are exploring what can be done.
Do you _honestly_ believe Dart is going to replace or threaten Javascript "very soon"? Enough to be willing to bet on that?
JS is the common compilation target of the web, and also happens to be a language that many programmers find tolerable enough to use directly.
As nice as it is to have multiple options of source languages for the web, there's a lot less value in having multiple options for compilation targets, as well as greater costs (particularly given how tied execution engines are to browser engines, so that you really need a separate engine for each compilation target for each browser engine. Having a reliable, good-enough cross-browser target language that is a the intersection of the JS supported by each browser engine is easier than doing that same thing for multiple different target languages.
A new target language is going to have to offer really compelling improvements in execution to make sense to compete with JS in that role on the web.
As stated below, I will probably remove this Introduction, since it seems to distract from what this article is about. I hope you consider reading the article anyway.
"Google is changing the monopoly of JavaScript by implementing the Dart VM in their own browser."
As far as I know community doesn't care much about Dart [1] and they are concentrating on further enhancement on ECMAScript.
[1] : http://en.wikipedia.org/wiki/Dart_%28programming_language%29...
http://news.dartlang.org/2013/12/ecma-forms-tc52-for-dart-st...
You can take a look at :
http://www.infoworld.com/article/2608454/web-development/goo...
https://en.wikipedia.org/wiki/Dart_%28programming_language%2...
If this is so, author might want to view his page in a NoScript enabled browser. Why should the front image show itself through JavaScript if JS is on its way to meet dodo the bird?
Also, gray text on white background?
I think that Javascript can do some awesome things client-side (and I have used them to do that), but when you leave the server, you lose a lot of predictability and that can ruin the user experience.
I worry that if we push too much onto the client, then we're asking them to do all the work while we sit back and take advantage of them, for marginal benefit to the user.
For certain definitions of free.
I've found that sites which abuse this tend to be much less responsive and can even cause my laptop fan to start spinning like crazy
Chrome ships a Dart VM and hopefully Mozilla, Apple and Microsoft will follow suit one day.
Google ships a special Dart-enabled version of Chromium (Dartium) with the Dart SDK. Chrome, however, does not currently ship (with) a Dart VM.
That alone discredited the article a bit. How can one be so confident of something that is highly improbable?
[1]: https://en.wikipedia.org/wiki/Dart_%28programming_language%2...
I will probably remove that statement though, since a lot of people seem to have extremely strong feelings about that, and are distracted from what this article is actually about.
Sometimes, depending on the team and the project, it will make sense to store at least some of that complexity in the HTML.
They were supposed to be awesome because they didn't require code. Looking closer, they'd just replaced code with declarative config files that spread a given piece of functionality across multiple files/formats that were sometimes harder to debug.
Each layer implemented comes with additional complexity, not less. The real solution always seems to come down to simplicity and minimalism. To my mind, it's always seemed that limiting the number of technologies employed is a useful goal.
Usually, it forces all kinds of artificial constraints on the app, such as atomic ratings counts when a looser, more cache-friendly requirement would suffice, etc.,
They maybe able to access the static version, but how about their participation? What if they need to login to get access to certain information?
I just learned that certain screen readers have some support of JS. But does it work in general?
I agree the static pages would be faster, but I feel like there is dynamic content that should always be rendered. Login pages for example are often linked in a dynamic menu.
"Create an AJAX request to the location (eg.: /about.html). Change the URL in the browser with the history API (this way, the back and forward buttons still work in the browser). Show a loading animation that the content is now being loaded. When the content is loaded, parse it to extract the contents of #main (you can help yourself there by adding markers in your HTML) and replace the content of your current #main section with the one you just loaded. Make sure that you handle all the links in your new #main content so they will act the same and fire off any BrowserScript required for the page that just loaded."
Aside of usability issues (what if the user has JavaScript disabled?), I don't really get how search engine spiders will be able to index the web site.
All the endpoints serve static html. I have no idea what the point in ajaxing it is (so you can stick in a pointless animation I guess). However it would degrade nicely, and search engines would be unaffected
It becomes necessary when you have elements that you want to persist on your page. That might be an audio player or the state of a menu that you want to avoid painting.
It's just about a better UX for your users.
The downside of course is that rendering different HTML based on your user, their location, cookies, user-agent, etc. is really freakin' convenient. And if you commit to static HTML, you have to do all of your customization on the client, and load real-time data with an AJAX call.
But if you want a highly-performant site, the tradeoff is worth it.
Anyway, reading on to the implementation section, this stuff sounds pretty standard, and people have been doing this for many years. Some implementation details changed (pushState, hashchange, etc), but this approach is ancient.
I mean, if you just want to describe a simple technique, there's no need write a long, vague and controversial introduction..
Doesn't the scroll bar serve as an indication?
Regarding SEO/performance for serving static HTML, many frontend frameworks provide a mechanism for rendering content on the server. For example, React.renderComponentToStaticMarkup (http://facebook.github.io/react/docs/top-level-api.html#reac...) can be used to render each static page on the server before sending it over the wire.
Also, I'm not sure how you reduce complexity by coupling view logic with backend datastore logic. In my experience it's far more maintainable to separate the backend and frontend, communicating between them via a REST API/web sockets. That way, everything is independently unit-testable and can be integration tested as well.
Doing this is a horrible waste of resources.
Also
No, not with any kind of intermediate caching (assuming not all resources have identical cache lifetimes)
It's not really: we don't have a proper caching infrastructure anyway to conserve both CPU cycles and bandwidth by allowing the whole page to be cached and just minor fragments to be loaded dynamically. Back in the days, when most individuals/offices/ISPs would have some sort of cascaded Squid setup, it was more helpful.
As for caching in the client itself: possible and useful (provided the user will load the page many times per day), but not helping with the "re-rendering for each user" part as far as bandwidth is concerned.
The rendering effort itself is largely a non-issue. If your web framework is inefficient and you run out of juice on the server side, you can simply cache the static parts of your page with memcached or even use some setup with ESI on a load balancer.