views:

77

answers:

2

I'm working with a third-party search api, and am rather enjoying keeping pretty much the entire application on the browser side. The xml is digested entirely with javascript, and I'm rendering complex result objects dynamically, using a javascript templating engine. There are few page reloads happening, and lots of fancy javascript going on.

It feels clean to me to keep everything on the javascript side. It's going to make deployment much easier, and it's nice to have all my code in one place. I'm trying to be just as rigorous about coding well with javascript as I would were I coding in java, and so far things seem to be working pretty well. I'm making an effort to work TDD style, using YUI test, and am optimistic that this will make the inevitible cross-browser bugs easier to catch and fix. The code size is not miniscule, but it's not too bad, and I plan to minify it before deployment, which should reduce it to about 2/3 of what it is now.

Are there drawbacks I'm not considering? Any other proponents of front-siding application logic here?

A: 

You should use AJAX only when it actually improves user experience. It is very annoying when trivial functionality requires JS needlessly. I would expect (no idea if it's the case for your app) to be able to enter a search, get the results, and page through the results all without JS.

There's nothing wrong with "extras" like AJAX paging or search refinement. But the essentials should be there either way.

Matthew Flaschen
+4  A: 

There are few page reloads happening, and lots of fancy javascript going on.

There is one large drawback to relying too heavily on JavaScript. Remember that whenever you design a web application you should base it on the premise that the user doesn't have JavaScript enabled - although this is a minority there are still a lot of users who don't have it enabled for whatever reason, and if your application relies too heavily on JavaScript in its fundamental operation, then it won't be accessible to those who disable JavaScript.

Whenever I write pages that have JavaScript or AJAX functionality I always make sure to have a secondary way of information being displayed or submitted, in case JavaScript is turned off on the user's browser. Of course this often isn't necessary for aesthetics - menu items sliding along a menu bar when clicked and the page is changed won't affect the core functionality of the page if JavaScript is turned off and they simply act like static links; however for core features such as inputting data and having results displayed, you should ensure to provide backup methods that are employed when JavaScript is not enabled.

Perspx
Good thoughts. The client's site doesn't work at all if javascript is disabled, so I'm no so worried about excluding non-js folks in this particular case.
morgancodes
That was my point - by designing your site like that you effectively block out that group of people.
Perspx