gagarine
gagarine

Reputation: 4338

How to use backbone.js to make a site also functional with client without JS

Take a look at http://www.usatoday.com, the website is made with backbone.js but work perfectly without.

I don't think they use somethings like http://phantomjs.org.

Someone know how they did that?

Thanks

P.S. I also send a mail to usatoday, if they answer and give me the permission I will report her what they say.

Upvotes: 2

Views: 727

Answers (1)

Jani Hartikainen
Jani Hartikainen

Reputation: 43243

They use a technique called progressive enhancement.

Essentially, this means you write the basic site without JS, and only add JavaScript on top of it later to improve the functionality.

There is nothing particularly special to it - the server simply sends the full HTML for the page which can be used to render the site instead of using Backbone to generate the markup on the fly from templates.

To be more specific about the techniques used in this case, it looks like they are generating the content mostly on the server even when using Ajax to load it.

When changing pages with JS enabled, they send the full page content markup from the server. Most likely this is done so that they can improve code reuse between the JS and non-JS versions of the site.

The HTML-block that is sent seems to contain some JSON. Most likely this is loaded for their client-side implementation so it knows what content you are currently viewing.

Upvotes: 2

Related Questions