Show HN: CMS.js – Fully Client-Side JavaScript Site Generator
cdmedia.github.io
cdmedia.github.io
(I'm speaking of the demo, not the actual site describing it --- although I thought it would be hosted with itself.)
As for the idea of turning static content sites into client-side JS-rendered apps, that gets a strong disapproval from me. Why? It's needless complexity (instead of generating the HTML once and storing it on the server, every single visitor has to regenerate it on their machine), bad for accessibility, and very much against the principle of the Web that information should be easily linkable and retrievable. I can understanding using JS to do "app-ish" things that wouldn't be possible with static pages, but this is reinventing the wheel and making it square.
That's only true if you use 'view source'. If you open up dev tools, all of the elements are rendered in full and live updated as they change.
Client-side rendered apps are quickly becoming every-where rendered apps. They can now work isomorphically, on the desktop, and on mobile.
> every single visitor has to regenerate it on their machine
This is a false premise. For server-side view rendering, the view is tightly coupled to the data. The majority of the payload will be made up of dynamically generated (and non-ideal for caching) HTML structure. When all the user really needs is data.
Rendering apps on the client-side allows fetching partials and content data piecemeal, which is ideal for caching. Views can be cached at the HTTP layer, directly in the app, or both. This will be especially useful once HTTP/2 (ie connection persistence) are in common use.
-----
We're moving past the days of the static web. Especially, now that it's trivial to pull data from many different sources on the client-side.
What really never make sense was rendering the view on both the server-side and client-side (often times using 2 view template engines). Fortunately, that practice is becoming less common.
Maybe that's not directly SEO but it is indirectly. Good open graph data makes links, at least on Facebook, arguably more compelling which makes them more likely to be clicked and/or shared which may lead to better SEO
For a blog or CMS this is probably not the case. The majority of the page is going to be the same for all users. Maybe you have something at the top of tbe page showing the user is logged in, and admin links to edit it, but that's probably about as dynamic as you will get.
> Rendering apps on the client-side allows fetching partials and content data piecemeal, which is ideal for caching
Yes.. but why? 99% of websites aren't going to have enough traffic that this would cause load issues on the server. On the client the browser probably does a better job of caching pages than you could.
For something more complicated that a blog or CMS you need to think about security. It's not a trivial task to cache something and securely serve it to only people who have an active session and are authorised to view it.
> They can now work isomorphically, on the desktop, and on
> mobile.
So can plain HTML. Without any needless scripting. > We're moving past the days of the static web.
We are not. Maybe you are, we can wait till you come back. > Especially, now that it's trivial to pull data from many
> different sources on the client-side.
HTML is even more trivial.client side rendering + json apis on the server are the holy grail of openness (esp with an MIT licensed client)
Excess layers of indirection come when you try do view generation on both the server and the client.
Many server frameworks currently follow this approach. Generate the view scaffold using templates on the server-side. Then request partials asynchronously on the client and generate additional views client-side using a completely different framework.
Shifting all of the view generation to the client frees up the back-end devs to focus all of their time/effort on the important part. Building and scaling the data infrastructure.
Not to mention, shifting the view layer client-side reduces resource requirements on the back-end.
The previous generation of front-end SPA frameworks frankly sucked in terms of performance, leading to a bad user experience. There were 2 primary reasons why. All data persistence/binding happened directly on the DOM, and all execution was handled on the main execution thread.
The latest generation greatly improves the experience by using new techniques such as data persistence/diffing via the virtual DOM, and handling all non-rendering logic on a background worker thread.
Because... those never lie. /s
The latest app frameworks decouple client-side application logic from the view rendering layer. Meaning you can use the same application logic on your web app as you use on mobile EXCEPT the view on mobile will be rendered natively. Not through a hacky, slow, inconsistent embedded web view. Native native.
If the approach is successful as the framework devs expect, mobile app development (and the app ecosystem as a whole) will go the way of the dinosaur.
Pulling data from many sources on the server requires proxying requests to third parties and providing inline caching of the responses for performance reasons. Despite the fact that the source you're proxying to likely already implements their own caching strategies.
Have fun addressing bugs caused by cache invalidations when you're dealing with multiple caching layers.
Not to mention the increased memory/computation footprint incurred from hosting the equivalent of a database view of an entire third party service on your backend.
Or, you could just request the data directly on the client side.
That's what I mean when I say 'reduced complexity.' Unless you consider setting up CORS whitelisting and some AJAX requests to be really difficult. Then, carry on.
Rendering the content via JavaScript is slower than just having it in your HTML. It's true that JS execution has become insanely fast, however, initial JS execution is not as fast, because it requires that JIT to kick in. Even if JS execution becomes infinitely fast, you still have to work with the DOM, which is horribly slow and there are no known ways to make it fast. Google, Yahoo and others have prove with hard numbers that users care about speed, even when we are talking about milliseconds.
I highly recommend doing some research on how browsers and caching actually work before falling into the pit of false belief.
Also, tricks like that are what users generally recognise as speed - similarly Twitter's optimistic xhr submission appears to work instantly, then goes off and actually does it's thing retrospectively.
Fwiw I think a fully client side js cms app is a moderately rubbish idea for a variety of reasons, but js rendering of dynamic content absolutely has merit.
It's a little more nuanced than slamming somebody's 'pit of false belief' because they like client view rendering. :)
As much as I like site generators and I'd find this a good idea for some purposes I wouldn't state it is a replacement for static sites generators.
> That's only true if you use 'view source'. If you open up > dev tools, all of the elements are rendered in full and > live updated as they change.
If one attempts to view the demo with client side javascript turned off - one gets a completely blank page. The very point to a static site generator is the word "static" which is generally taken to mean that the actual rendering of the content requires only HTML rendering (no javascript (or php or ??) code execution, server side or client side).
If you want to render your blog in client side js AND use fresh-from-the-oven js features, the least you can do is include a polyfill.
Render the client on the server, then push the rendered markup and the client state to the browser where the client takes over again.
This paradigm is fundamentally different from the Angular1-style "render everything in the browser" and "maybe pre-render on the server, then discard that on page load" approach. If anything, it's closer to the traditional "render everything on the server, then apply enhancements in the browser" approach of the pre-SPA days.
Basically Angular2 renders a completely interactive view that captures any user events that occur while the app is bootstrapping in the background. Once the app is loaded, the events are replayed to make the user experience consistent.
React and Angular2 are fundamentally just different flavors of the same underlying infrastructure. React is more de-centralized and composition based. Angular2 is more centralized, monolithic, OOP, architecture based.
They have even eluded during presentations that the 2 core dev teams have been in direct contact to work out some technical details.
From what I've heard, Ember.js uses these same approaches. Kinda makes me question how much of this started with Ember and was later adoped by React and Angular.
Needless over engineering for displaying text on a page.
Yep, and the worse offender seems to be Quora that seems to have its main page receive all its data from java script (which as a side effect makes scrolling annoyingly slow). But it's probably on purpose since they are preventing copy/pasting so it's impossible to quote text from their website without linking to them in some way.
I totally agree with you here.
Sites using JS only cannot be parsed by standard tools---I can't cURL the page, use wget, use a text-mode browser, etc. This fundamentally breaks interoperability, and limits users' freedom to use the tool/browsers they want to use the web. Users who wish to disable JavaScript to browse the web---be it for security, privacy, philosophy[0], or all of these things---are forced to either enable JavaScript or not read your website (I fall into the latter).
I write more JavaScript than any other language. I understand the community, and the rationale. But I know enough to know that I should disable JavaScript when browsing the web (except for select cases, and the software must be Free), and I still use command-line tools aggressively, even for the web. Please do your best to respect those who use the web as it was intended.
Keep hacking, but consider fallbacks, too!
[0]: https://dyladan.me
In software development especially, our community of hackers is our most valuable asset.
The choice to block JS seems a bit weird to me. JS, to my eyes, is very different to binary code running in userland. It is a sandboxed language with very clear restrictions to what it may do, it is easily read and verified (view source, pass it through a prettifier, and all that's left to fix is the variable names), and even hackable (we get a JS console in browsers).
What is it that makes JS so dangerous it must be blocked 100% ?
specifically, are there javascript-only (or js+css+html only) exploits in recent chrome or firefox ?
I think CMS is a poor choice for a name, when there is no interface to 'build' the site's pages. I'd call it something like 'website generator backed by github'.
Full Disclosure: I built Zammu.
But this really is a SPA that can grab markdown files from your Jekyll site hosted on Github or a Apache web server, convert them to HTML and render on client site with JS.
What is the point?
For easy theming, I suggest you to take a look at the Classless Project, which will be super easy to integrate to in your case and will bring many already made themes with it -- and much more to come.
The ursprung[2] micro CMS is integrating Classless with success to this day.
The only thing I'd suggest is, use ES6 instead of CoffeeScript or provide an ES5 copy of the code.
The CoffeeScript code you see is for the bookmarklet used on the playground. It is old code, coded in a rush, most for proof-of-concept. I'm slowly rethinking this playground and theme development stuff, so this is going to be replaced.
I'm planning to eventually extract the good bits, and adapt it to work with Jekyll files. Front-matter support is the last major road block.
Google shouldn't have any issue indexing AJAX-loaded content. On my site it's the Angular2 router that's really screwing SEO. You can test it out using the 'Fetch as Google' tool.
The load time should be much better now.
No matter how much optimisation you're doing, you're still destroying the progressive loading of HTML pages and the ability for my browser to tell me how my page is loading.
It may be a fun project, but it's not based on sound technical decisions, in my humble opinion.
Semantic UI adds 700KBs of CSS, which seems like a lot more than your site should need. Even if this were a static rendered site, the browser would delay rendering anything until the CSS was downloaded.
Guess I should choke down my excitement and stay in stealth mode until I'm ready next time.
The entire app is server-less and hosted on a S3 bucket.
Gzipping the content should be an easy addition to the build process.
I'm using approximately 2% of what Semantic-UI is capable of. Fortunately, Semantic-UI provides a set of tools to trim it down to a production-ready bundle.
In addition, Google will likely trim more of the fat from Angular2 in upcoming releases.
The big one I'm concerned about is Rxjs. The size of the lib is massive considering it only provides support for observables and observable extensions.
Trust me, I'm painfully aware of how slow it is right now.
Thanks for the feedback though. I do appreciate it.
The time to bootstrap the app is about 1.5 seconds. There's room for improvement but I don't expect any massive gains since I can't isomorphically pre-render without a server back-end.
I use Jekyll for blogging and generating my portfolio site too, but right now I can only update my those from my own laptop with my Jekyll install which is not always great. CMS.js would be something else... My dream would be a simple PHP based CMS for my Jekyll install though.
"A static site generator that runs entirely client-side? How's that possible? Surely it needs to write to the server at some point..."
My guess is it will be OK for the text, but links will be out of whack so bots won't really "crawl" the site. Then again, maybe advanced bots will run the js?
also, I know words in h-tags are usually "counted" as more important, so that logic won't work with raw .md
there is no text, the page is empty, the linking is not the first priority at this point
a robot to be able to read the text would already need to run the js in the first place
but the concept is interesting let's do a CONTENT management system but be completely invisible to any search bots so our CONTENT never ever get referenced and searchable on the Internet
It would probably reduce the score though.
sure Google is the bigger one and you have to be referenced on it, but there are also other indexes where you want to be referenced, and those are maybe not using robots as advanced as google.
So, as I said, for your normal robot crawler visiting the page, the page is empty, no content.
That Google have already solved the problem does not mean that everyone else did.
Why do you think prerender.io exists ? to solve that very same problem
From a SEO point of view, which was the question I was answering, it is ridiculous to serve a page without content to an indexing robot crawler.
-4 ? go all educate (F) yourself :)
I mean here a list of active robots crawler https://udger.com/resources/ua-list/crawlers
here an example of how people apply that in practice https://gist.github.com/Stanback/7028309
also last but not least, yeah GoogleBot parse/read JS, but do read their guidelines https://googlewebmastercentral.blogspot.fr/2014/10/updating-...
"Make sure your web design adheres to the principles of progressive enhancement"
serving a blank page, that you then fill with content using pushState is not what I call progressive enhancement
but hey no problem it's JS, so to correct that SEO problem they will probably do a whole render of the page server-side with something like PhamtomJS and serve those "special" pages to bots
which I think is totally insane
Explanation of it: http://searchengineland.com/how-to-use-fetch-as-googlebot-li...
go there http://web.archive.org/web/20160119113309/http://cdmedia.git...
view source, that's what archive.org_bot is referencing eg. no content whatsoever
if/when this site die, when you will browse the link above, you will see a blank page
I would even say that on web.archive.org the effect is even more vicious, if you don't know any better, because you see the page archived you think it is indeed archived when in fact it's not
but don't despair, there are other way to have the exact same result for your SEO
tell me how it is different than rendering the whole page as Flash SWF file ?
GoogleBot can read/parse SWF and even understand when dynamic text/xml is loaded https://googlewebmastercentral.blogspot.fr/2008/06/improved-...
since 2008
it's cloned to danielovich.github.io but then it breaks!
:/
bummer...