1

Consider an application that contains a number of pages with a relatively large amount of javascript present, or a predominantly JS powered application. The script handles a number things, such as:

  • Client side validation
  • Showing/hiding entry sections when appropriate
  • Autocomplete when filling text fields
  • Date pickers

etc.

If we consider the case that javascript is a requirement to use the site (e.g. not public internet site), I am wondering what the best practice would be for handling an unexpected error that occurs at runtime that causes some of the functionality to no longer be present (e.g. sections remain hidden, calendar controls become empty textboxes etc). The options that I can think of would be:

  1. Try to fail gracefully and have a page that will respond with no script present (gets trickier the more complex a page/app becomes).

or

  1. Try..Catch round all the critical code, and on error, display a message, or redirect to an error page.

I am curious if anyone has 'best practice' suggestions for this?


My motivation for looking into this comes after an obscure bug with an earlier version of jQuery for a user in IE10 running in compatibility mode. This question is not about that, but the knock on affect was that a lot of the code in a document ready handler in jQuery was not loaded, resulting in significant degredation in usability.

2

You should try weighting it on the amount of critical pieces of the application that has failed. Weighting may seem a bit tough, but think of it from an end-user point of view. Try making the app fail and see what functionality remains when certain pieces fail. You can then determine the critical failure level that should be used as the point of redirection to a 404 or a raw-HTML version of the application.

If an entire piece of JQuery just didn't load, you could either direct the user to a 404 error page, or do what Google does and use a raw HTML version as the redirect when the JS fails.

Consider an application that contains a number of pages with a relatively large amount of javascript present, or a predominantly JS powered application.

I also don't understand why you have page loads if your application is JS-heavy. Have you considered using a client-side MVC/MVVM JS framework that runs on a single 'page'? Eg. AngularJS or EmberJS

The script handles a number things, such as:

Client side validation

I hope you're doing server-side validation as well, otherwise you could compromise the entire database and security of the application.

  • We do have server side validation as a matter of course, it's more the hiding/showing & ajax based functionality that is problematic. We have page loads as this is a fairly traditional intranet style application, just with quite heavy use of javascript within the page. It's not really suitable for a single page style application. – Paddy Nov 23 '13 at 7:36
  • Can you explain what the application is being used for? – Joe Nov 23 '13 at 14:22
  • It's more of a general question than specific to this app. – Paddy Nov 23 '13 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.