Hybrid page-based / single-page web-app (Angularjs, Ember.js) with progressive enhancement?
Asked Answered
S

2

23

I'm wondering if anyone has found a solution to this problem. Is there a way to get the best of both worlds:

  • build a page-based site, with permanent links, accessibility, SEO, and graceful fallback / progressive enhancement (basically all the best practices of web development)
  • and, for those with javascript, a responsive front-end experience with ajax loading of content, no page refreshes while navigating the underlying site pages, minimal redundant downloading of scripts/content/css/etc. (all the benefits of a client-side framework like AngularJs or Ember.js)

I see a few major sites are able to manage this (gmail, stackoverflow), and I see that Jeff's new site builds a bare-bones version of the site in a noscript tag.

  1. Is the solution to the hybrid page-based/single-page app to build two versions of the site, send both, and let the client decide which it can show? (is this what gmail does?)
  2. Or is the problem that AngularJS et al. are simply not designed to allow for graceful degradation?

It hurts my DRY brains to think that #1 is the answer.

(The reason I am focusing on AngularJs is that I like its support for html templating, declarative style, and its attempts to fix js scoping. Ember and other frameworks are excellent too; maybe one of them would be a better fit for a hybrid site?)

Seavey answered 17/4, 2013 at 15:27 Comment(0)
B
14

This questions is a bit of a nuanced one because the answer is "it depends". For example you mentioned Gmail, there isn't any reasons whatsoever that an application like Gmail would need to be indexed for SEO, though depending on what you want or need to support you may want to ensure you can support not having Javascript.

However even the "no-javascript" argument is getting tired and weak these days, at least for the class of "web applications". If I want to use a Windows application I need Windows, if I want to use a javascript powered web application it isn't unreasonable to assume that I'm going to need a browser that isn't crippled to use it.

However back to your question I can only speak to AngularJS because I'm the most familiar with it. For the most part it does allow you to support a progressive enhancement approach, though don't expect to use things like URL routing if this is what you want to support. What you can do is use AngularJS controllers, bindings and directives similar to how you might use jQuery as a way of enhancing the interactions and behaviours of the page.

Just keep in mind this approach will seriously limit what you can do with Angular (or Ember for that matter) and it may start to be debatable what you are getting from this approach that you couldn't easily do with jQuery alone.

The alternative these days is to do what sites like Twitter are doing. That is basically serve fully rendered HTML from the server for any view on the initial load and then use Javascript for subsequent loading and enhanced UI behaviour. This is very effective (though perhaps quite challenging to implement) if you really need to support browsing with and without Javascript and has the added benefit of improve the rendering/load times for the first request. Again "it depends" because it depends a lot on how your site actually works if it is possible to use this. You have to design for it, and it isn't going to be trivial or easy.

Update:

For what it's worth we are taking the Year of Moo approach and rendering the pages that need SEO using PhantomJS and sticking the cached initial state of them somewhere to serve them up. We have a rake task we run on deployments to update this. Again this is just the initial state but it helps get around the issue for now.

Things are always changing though and I'm sure I will have changed my mind on this approach in a year or so.

Blew answered 14/10, 2013 at 17:50 Comment(0)
C
2

Have you read Google's Making AJAX Applications Crawlable. You can have JavaScript single page app and crawlable content.

If you stick with angular, there is interesting article: Turns out it is possible to have your AngularJS application indexed

Callboard answered 2/5, 2013 at 23:38 Comment(1)
Now Google indexer will behave like browser and render the page as they do, so you don't really need to do anything to make your Angular better suited for indexing: googlewebmastercentral.blogspot.no/2015/10/…Cresset

© 2022 - 2024 — McMap. All rights reserved.