Home > Programming > JavaScript and the end of progressive enhancement

JavaScript and the end of progressive enhancement

Progressive enhancement is the Right WayTM to do things in web development. It works like this:

  1. Write the HTML for your content, 100% semantically (i.e. only the necessary tags to explain the meaning of the content).

  2. Style the HTML using CSS. You may need to add hooks to your HTML in the form of classes and ids for the CSS to target.

  3. Add JavaScript enhancements to the interface, but only enhancements.

Parallel to this, the functionality of the site/app is progressively enhanced:

  1. All navigation must happen via links and form submissions – don’t use JavaScript for navigation.

  2. Add JavaScript enhancements to navigation, overriding the links and form submissions, for example to avoid page reloads. Every single link and form element should still work when JavaScript is disabled.

But of course you knew that, because that’s how you roll. I’m not sure this is the way forward though. To explain why I’ll need to start with a bit of (over-simplified) history.

A history lesson

Static pages

Originally, most sites on the web were a collection of static HTML pages saved on a server. The bit of the URL after the domain gave the location of the file on the server. This works fine as long as you’re working with static information, and don’t mind each file having to repeat the header, footer, and any other shared HTML.

Server-side dynamism

In order to make the web more useful, techniques were developed to enable the HTML to be generated on the fly, when a request was received. For a long time, this was how the web worked, and a lot of it still does.

Client-side dynamism

As JavaScript has become more prevalent on the client, developers have started using Ajax to streamline interfaces, replacing page loads with partial reloads. This either works by sending HTML snippets to replace a section of page (thus putting the burden of HTML generation on the server) or by sending raw data in XML or JSON and letting the browser construct the HTML or DOM structure.

Shifting to the client

As JavaScript engines increase in speed, the Ajax bottleneck comes in the transfer time. With a fast JavaScript engine it’s quicker to send the data to the client in the lightest way possible and let the client construct the HTML, rather than constructing the HTML on the server and saving the browser some work.

This raises an issue – we now need rendering code on the client and the server, doing the same thing. This breaks the DRY principle and leads to a maintenance nightmare. Remember, all of the functionality needs to work without JavaScript first, and only be enhanced by JavaScript.

No page reloads

If we’re trying to avoid page reloads, why not take that to its logical conclusion? All the server needs to do is spit out JSON – the client handles all of the rendering. Even if the entire page needs to change, it might be faster to load the new data asynchronously, then render a new template using this new data.

Working this way, a huge amount of functionality would need to be written twice; once on the server and once on the client. This isn’t going work for most people, so we’re left with two options – either abandon the “no reload” approach or abandon progressive enhancement.

The end of progressive enhancement

So, where does this leave things? It depends on how strongly you’re tied to progressive enhancement. Up until now, progressive enhancement was a good way to build websites and web apps – it enforced a clean separation between content, layout, behaviour and navigation. But it could be holding us back now, stopping the web moving forward towards more natural interfaces that aren’t over-burdened by its history as something very different to what it is today.

There are still good reasons to keep using progressive enhancement, but it may be time to accept that JavaScript is an essential technology on today’s web, and stop trying to make everything work in its absence.

Or maybe not

I’m completely torn on this issue. I wrote this post as a way of putting one side of the argument across in the hope of generating some kind of discussion. I don’t know what the solution is right now, but I know it’s worth talking about. So let me know what you think!

Appendix: Tools for this brave new world

Backbone.js is a JavaScript MVC framework, perfectly suited for developing applications that live on the client. You’ll want to use some kind of templating solution as well – I use jQuery.tmpl (I’ve written a presentation on the topic if you’re interested in learning more) but there are lots of others as well.

Sammy.js (suggested by justin TNT) looks like another good client-side framework, definitely influenced by Sinatra.

If anybody has any suggestions for other suitable libraries/frameworks I’ll gladly add them in here.

Edit: I’ve now written a follow-up to this post: The end of progressive enhancement revisited.

  1. January 8th, 2014 at 01:54 | #1

    For a brilliant retro style MMORPG, check out Shin ME! Aside ranging from that, this apple iphone app enable your entire family to play on 10,000 unique grids, with 5 defined difficulty levels in match your Sudoku mastery.

  2. February 24th, 2014 at 08:25 | #2

    Asking questions are in fact pleasant thing if you are not understanding anything entirely, however this piece of writing presents pleasant understanding yet.

  3. April 16th, 2014 at 20:08 | #3

    The treatment is relatively painless and gives very good results for those that are good candidates. If you want to eliminate hair for good, get laser hair removal in Sydney. Following the treatment, be prepared to sense a couple of common discomforts like redness, swelling, and itching. Laser hair removal works by applying a laser beam that produces energy that is absorbed by the dark pigments within the hair follicle. Clark places a focus on prevention of disease and aging, providing an array of treatments, including Upper East Side New York laser hair removal, Botox and dermal fillers, among other treatments.

    My webpage … [Maryland DUI Attorney](https://www.youtube.com/watch?v=VJJynKMuV4I “Maryland DUI Attorney”)

  4. April 29th, 2014 at 01:50 | #4

    I’m not sure where you are getting your info, but great topic. I needs to spend some time learning much more or understanding more. Thanks for great info I was looking for this info for my mission.

  5. April 30th, 2014 at 04:54 | #5

    なまこんはさっさと記者辞めて 電車乗っても高校生全然してないだろ なんか魚の餌になりそうな虫っぽいのが入ってるね 接客業なら、一定の基準、必要だろ。メーカーでも営業なら基準ある 工藤もああいうショートならいいのに何でバレー部みたいにしか切らないの?亀井や安倍のときみたいに可愛さがないショートって損しかないと思うんだけど サイズがあってない奴大杉ww

    05/20 [雑誌] non-no7月号 ▽薔薇色のブー子取材 ドンキホーテ通販 自転車 [16 カラコン](http://is.gd/4GJjV3 “16 カラコン”) ずなさんの方が意味がわからないですよw

  6. May 5th, 2014 at 17:45 | #6

    For hottest news you have to pay a visit the web and on world-wide-web I found this website as a best site for most up-to-date updates.

  7. June 11th, 2014 at 05:01 | #7

    My brother recommended I might like this web site. He was entirely right. This post actually made my day. You can not imagine just how much time I had spent for this information! Thanks!

  8. June 21st, 2014 at 05:47 | #8

    Most certainly you can’t afford to spend ridiculous amounts on carpet cleaning each year.

    Once you are able to make your customers believe in your ability to make their clothing look great, you will never be lack your own fair measure of attention and popularity. I bet you need to keep the much-loved dress looking amazing after a period.

  9. July 23rd, 2014 at 22:06 | #9

    I love what you guys are up too. This kind of clever work and reporting!

    Keep up the amazing works guys I’ve added you guys to blogroll.

  10. July 28th, 2014 at 06:09 | #10

    The cost of Remortgage Rates rise by 25% to bring them into line with men. I was told it was not. Having to worry about, you may want to also consider the type of job a policyholder has done and whether he or she suffers certain medical conditions.

Comment pages
1 2 1071
  1. May 9th, 2011 at 18:31 | #1
  2. May 29th, 2011 at 23:18 | #2
  3. July 9th, 2013 at 21:58 | #3

Comments parsed as Markdown.